6857948: Calling a constructor with a doubly bogus argument causes an internal error

Problem when constructor resolution returns an erroneous symbol

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2010-08-05 09:45:25 +01:00
parent 156e82c164
commit fa2cb78a09
3 changed files with 30 additions and 7 deletions

View file

@ -1594,13 +1594,15 @@ public class Attr extends JCTree.Visitor {
localEnv.info.varArgs = false;
tree.constructor = rs.resolveConstructor(
tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
tree.constructorType = checkMethod(clazztype,
tree.constructor,
localEnv,
tree.args,
argtypes,
typeargtypes,
localEnv.info.varArgs);
tree.constructorType = tree.constructor.type.isErroneous() ?
syms.errType :
checkMethod(clazztype,
tree.constructor,
localEnv,
tree.args,
argtypes,
typeargtypes,
localEnv.info.varArgs);
if (localEnv.info.varArgs)
assert tree.constructorType.isErroneous() || tree.varargsElement != null;
}

View file

@ -0,0 +1,18 @@
/*
* @test /nodynamiccopyright/
* @bug 6857948
* @summary 6857948: Calling a constructor with a doubly bogus argument causes an internal error
* @author Maurizio Cimadamore
*
* @compile/fail/ref=T6857948.out -XDrawDiagnostics T6857948.java
*/
class Foo {
Foo(String v) {}
};
class Test {
public static void main() {
Foo f = new Foo("Hello!",nosuchfunction()) {};
}
}

View file

@ -0,0 +1,3 @@
T6857948.java:16:32: compiler.err.cant.resolve.location.args: kindname.method, nosuchfunction, , , kindname.class, Test
T6857948.java:16:50: compiler.err.cant.apply.symbol: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, null
2 errors