Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
Consider the following:
interface A { def foo() {} } interface B extends A { def bar() {} } @groovy.transform.CompileStatic void test(A a) { if (a instanceof B) { a.foo() a.bar() } }
Variable expression "a" infers to "<UnionType:A+B>" due to instanceof screening. Since B extends A, a simple ClassNode for B should be sufficient.
The union types are harder to deal with for consumers. This is a variant of GROOVY-7333.
Attachments
Issue Links
- relates to
-
GROOVY-11290 STC: multiple instanceof checks produce different results
- Closed
-
GROOVY-11137 Improve support for union and intersection types
- Open