Skip to content

Commit

Permalink
GROOVY-6938
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Feb 24, 2021
1 parent 96a22f3 commit 625858c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,47 @@ public void testTypeChecked6882() {
runConformTest(sources, "CC");
}

@Test
public void testTypeChecked6938() {
//@formatter:off
String[] sources = {
"Main.groovy",
"import groovy.transform.ASTTest\n" +
"import groovy.transform.TypeChecked\n" +
"import org.codehaus.groovy.ast.expr.MethodCallExpression\n" +
"import static org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_TYPE\n" +

"@TypeChecked\n" +
"class G extends J<Integer> {\n" +
" Integer doSomething() {\n" +
" @ASTTest(phase=CLASS_GENERATION, value={\n" +
" def expr = node.rightExpression\n" +
" assert expr instanceof MethodCallExpression\n" +
" assert expr.objectExpression.text == 'super'\n" +

" def type = expr.objectExpression.getNodeMetaData(INFERRED_TYPE)\n" +
" assert type.toString(false) == 'J <Integer>'\n" + // was "J<T>"
" type = node.leftExpression.getNodeMetaData(INFERRED_TYPE)\n" +
" assert type.toString(false) == 'java.lang.Integer'\n" +
" })\n" +
" def result = super.doSomething()\n" +
" return result\n" +
" }\n" +
"}\n" +
"print new G().doSomething()\n",

"J.java",
"public class J <T extends Number> {\n" +
" public T doSomething() {\n" +
" return null;\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "null");
}

@Test
public void testTypeChecked7333() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5318,8 +5318,8 @@ private ClassNode getTypeFromClosureArguments(Parameter parameter, TypeCheckingC
return null;
}

private ClassNode makeSuper() {
return makeType(typeCheckingContext.getEnclosingClassNode().getSuperClass(), typeCheckingContext.isInStaticContext);
private ClassNode makeSuper() { // GRECLIPSE edit -- GROOVY-6938
return makeType(typeCheckingContext.getEnclosingClassNode().getUnresolvedSuperClass(), typeCheckingContext.isInStaticContext);
}

private ClassNode makeThis() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5098,8 +5098,8 @@ private static ClassNode makeSelf(final ClassNode trait) {
return selfType;
}

private ClassNode makeSuper() {
return makeType(typeCheckingContext.getEnclosingClassNode().getSuperClass(), typeCheckingContext.isInStaticContext);
private ClassNode makeSuper() { // GRECLIPSE edit -- GROOVY-6938
return makeType(typeCheckingContext.getEnclosingClassNode().getUnresolvedSuperClass(), typeCheckingContext.isInStaticContext);
}

private ClassNode makeThis() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5064,8 +5064,8 @@ private static ClassNode makeSelf(final ClassNode trait) {
return selfType;
}

private ClassNode makeSuper() {
return makeType(typeCheckingContext.getEnclosingClassNode().getSuperClass(), typeCheckingContext.isInStaticContext);
private ClassNode makeSuper() { // GRECLIPSE edit -- GROOVY-6938
return makeType(typeCheckingContext.getEnclosingClassNode().getUnresolvedSuperClass(), typeCheckingContext.isInStaticContext);
}

private ClassNode makeThis() {
Expand Down

0 comments on commit 625858c

Please sign in to comment.