Eric Milles created GROOVY-9769:
-----------------------------------

             Summary: STC: UnionTypeClassNode created for simple instanceof 
scenarios
                 Key: GROOVY-9769
                 URL: https://issues.apache.org/jira/browse/GROOVY-9769
             Project: Groovy
          Issue Type: Bug
            Reporter: Eric Milles
            Assignee: Eric Milles


Consider the following:
{code:groovy}
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()
  }
}
{code}

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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to