8037379: fix for JDK-8029569 doesn't cover all possible cases
authorvromero
Sat, 10 May 2014 00:46:47 +0100
changeset 24400 f05df7f58567
parent 24399 af1a0220d0fa
child 24401 0d793293862a
8037379: fix for JDK-8029569 doesn't cover all possible cases Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java
langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java
langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri May 09 15:37:12 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Sat May 10 00:46:47 2014 +0100
@@ -2768,7 +2768,7 @@
                         targetError = false;
                 }
 
-                JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT,
+                JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym.baseSymbol()).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT,
                                 that, exprType.tsym, exprType, that.name, argtypes, typeargtypes);
 
                 JCDiagnostic.DiagnosticType diagKind = targetError ?
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri May 09 15:37:12 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Sat May 10 00:46:47 2014 +0100
@@ -1435,7 +1435,7 @@
             return bestSoFar;
         } else if (useVarargs && (sym.flags() & VARARGS) == 0) {
             return bestSoFar.kind >= ERRONEOUS ?
-                    new BadVarargsMethod((ResolveError)bestSoFar) :
+                    new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) :
                     bestSoFar;
         }
         Assert.check(sym.kind < AMBIGUOUS);
@@ -2203,7 +2203,7 @@
                   List<Type> typeargtypes,
                   LogResolveHelper logResolveHelper) {
         if (sym.kind >= AMBIGUOUS) {
-            ResolveError errSym = (ResolveError)sym;
+            ResolveError errSym = (ResolveError)sym.baseSymbol();
             sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
             argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes);
             if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) {
@@ -2592,7 +2592,7 @@
                                 sym = super.access(env, pos, location, sym);
                             } else {
                                 final JCDiagnostic details = sym.kind == WRONG_MTH ?
-                                                ((InapplicableSymbolError)sym).errCandidate().snd :
+                                                ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd :
                                                 null;
                                 sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) {
                                     @Override
@@ -3000,12 +3000,12 @@
                     return true;
                 case WRONG_MTH:
                     InapplicableSymbolError errSym =
-                            (InapplicableSymbolError)s;
+                            (InapplicableSymbolError)s.baseSymbol();
                     return new Template(MethodCheckDiag.ARITY_MISMATCH.regex())
                             .matches(errSym.errCandidate().snd);
                 case WRONG_MTHS:
                     InapplicableSymbolsError errSyms =
-                            (InapplicableSymbolsError)s;
+                            (InapplicableSymbolsError)s.baseSymbol();
                     return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty();
                 case WRONG_STATICNESS:
                     return false;
--- a/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java	Fri May 09 15:37:12 2014 -0700
+++ b/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java	Sat May 10 00:46:47 2014 +0100
@@ -1,30 +1,8 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8029569
+ * @test /nodynamiccopyright/
+ * @bug 8029569 8037379
  * @summary internal javac cast exception when resolving varargs ambiguity
+ * fix for JDK-8029569 doesn't cover all possible cases
  * @compile/fail/ref=VarargsAmbiguityCrashTest.out -XDrawDiagnostics VarargsAmbiguityCrashTest.java
  */
 
--- a/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out	Fri May 09 15:37:12 2014 -0700
+++ b/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out	Sat May 10 00:46:47 2014 +0100
@@ -1,2 +1,2 @@
-VarargsAmbiguityCrashTest.java:33:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest
+VarargsAmbiguityCrashTest.java:11:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest
 1 error