Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.7
-
None
Description
Given the Java class
public class ContainsSet extends GroovyObjectSupport { private Set<File> files = new HashSet<File>(); public Set<File> getFiles() { return files; } public void setFiles(Set<File> files) { this.files = files; } }
the following Groovy code will not type check:
@TypeChecked private Set<File> modifyIdeaModel() { set.files += new File('foo') }
The failure is:
Error: Groovyc: [Static type checking] - Cannot assign value of type java.io.File to variable of type java.util.Set <java.io.File>
Without the @TypeChecked the code runs with dynamic Groovy.
Using the following Groovy class type checking the code above works.
class ContainsSet { Set<File> files = new HashSet<>() }
Attachments
Issue Links
- links to