8041713: Type inference of non-existent method references crashes the compiler

Wed, 04 Jun 2014 20:01:13 +0100

author
vromero
date
Wed, 04 Jun 2014 20:01:13 +0100
changeset 2412
bf8edbcae43a
parent 2411
71767cdf52a7
child 2413
fe033d997ddf

8041713: Type inference of non-existent method references crashes the compiler
Reviewed-by: mcimadamore

src/share/classes/com/sun/tools/javac/code/Type.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Attr.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Jun 03 20:00:01 2014 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Jun 04 20:01:13 2014 +0100
     1.3 @@ -72,13 +72,28 @@
     1.4  public abstract class Type extends AnnoConstruct implements TypeMirror {
     1.5  
     1.6      /** Constant type: no type at all. */
     1.7 -    public static final JCNoType noType = new JCNoType();
     1.8 +    public static final JCNoType noType = new JCNoType() {
     1.9 +        @Override
    1.10 +        public String toString() {
    1.11 +            return "none";
    1.12 +        }
    1.13 +    };
    1.14  
    1.15      /** Constant type: special type to be used during recovery of deferred expressions. */
    1.16 -    public static final JCNoType recoveryType = new JCNoType();
    1.17 +    public static final JCNoType recoveryType = new JCNoType(){
    1.18 +        @Override
    1.19 +        public String toString() {
    1.20 +            return "recovery";
    1.21 +        }
    1.22 +    };
    1.23  
    1.24      /** Constant type: special type to be used for marking stuck trees. */
    1.25 -    public static final JCNoType stuckType = new JCNoType();
    1.26 +    public static final JCNoType stuckType = new JCNoType() {
    1.27 +        @Override
    1.28 +        public String toString() {
    1.29 +            return "stuck";
    1.30 +        }
    1.31 +    };
    1.32  
    1.33      /** If this switch is turned on, the names of type variables
    1.34       *  and anonymous classes are printed with hashcodes appended.
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Jun 03 20:00:01 2014 +0100
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jun 04 20:01:13 2014 +0100
     2.3 @@ -2056,7 +2056,7 @@
     2.4                  tree.constructor = constructor.baseSymbol();
     2.5  
     2.6                  final TypeSymbol csym = clazztype.tsym;
     2.7 -                ResultInfo diamondResult = new ResultInfo(MTH, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) {
     2.8 +                ResultInfo diamondResult = new ResultInfo(pkind, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) {
     2.9                      @Override
    2.10                      public void report(DiagnosticPosition _unused, JCDiagnostic details) {
    2.11                          enclosingContext.report(tree.clazz,
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java	Wed Jun 04 20:01:13 2014 +0100
     3.3 @@ -0,0 +1,11 @@
     3.4 +/*
     3.5 + * @test /nodynamiccopyright/
     3.6 + * @bug 8041713
     3.7 + * @summary  Type inference of non-existent method references crashes the compiler
     3.8 + * @compile/fail/ref=DiamondPlusUnexistingMethodRefCrashTest.out -XDrawDiagnostics DiamondPlusUnexistingMethodRefCrashTest.java
     3.9 + */
    3.10 +
    3.11 +public class DiamondPlusUnexistingMethodRefCrashTest<T> {
    3.12 +    DiamondPlusUnexistingMethodRefCrashTest<String> m =
    3.13 +        new DiamondPlusUnexistingMethodRefCrashTest<>(DiamondPlusUnexistingMethodRefCrashTest::doNotExists);
    3.14 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out	Wed Jun 04 20:01:13 2014 +0100
     4.3 @@ -0,0 +1,2 @@
     4.4 +DiamondPlusUnexistingMethodRefCrashTest.java:10:55: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, doNotExists, , , (compiler.misc.location: kindname.class, DiamondPlusUnexistingMethodRefCrashTest, null))
     4.5 +1 error

mercurial