Skip to content

Fix code hover for type disjunction #1170

@eric-milles

Description

@eric-milles

Consider the following:

@groovy.transform.CompileStatic
void test(CharSequence cs) {
  if (cs instanceof Serializable) {
    cs
  }
}

The inferred type for "cs" within the if block is the type disjunction "CharSequence+Serializable". Hovering over "cs" produces an error:

java.lang.IllegalArgumentException: <UnionType:java.lang.CharSequence+java.io.Serializable>
	at org.eclipse.jdt.core.Signature.encodeQualifiedName(Signature.java:1373)
	at org.eclipse.jdt.core.Signature.encodeTypeSignature(Signature.java:1495)
	at org.eclipse.jdt.core.Signature.createCharArrayTypeSignature(Signature.java:1095)
	at org.eclipse.jdt.core.Signature.createTypeSignature(Signature.java:1293)
	at org.eclipse.jdt.core.Signature.createTypeSignature(Signature.java:1320)
	at org.eclipse.jdt.groovy.core.util.GroovyUtils.getTypeSignatureWithoutGenerics(GroovyUtils.java:259)
	at org.eclipse.jdt.groovy.core.util.GroovyUtils.getTypeSignature(GroovyUtils.java:202)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectRequestor.handleMatch(CodeSelectRequestor.java:254)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectRequestor.acceptASTNode(CodeSelectRequestor.java:144)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions