Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
3.0.7
-
None
-
None
Description
I have the following Groovy program
@groovy.transform.CompileStatic class Main { static Integer bar(Object o) { if (o !instanceof Integer) { return 0 } else { return o } } }
Actual Behavior
The program does not compile, and I get the following error.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 7: [Static type checking] - Cannot return value of type java.lang.Object on method returning type java.lang.Integer @ line 7, column 9. o ^ 1 error
Expected Behavior
Compile successfully.
Attachments
Issue Links
- duplicates
-
GROOVY-8412 Support !instanceof flow typing for else case
- Closed
- relates to
-
GROOVY-6429 flow typing detects unexpected error at if-else flow
- Closed