changeset 3347:615a70db794b

8037379: fix for JDK-8029569 doesn't cover all possible cases Reviewed-by: jjg
author vromero
date Sat, 10 May 2014 00:46:47 +0100
parents 94aca852a4d0
children aa1236dbf865
files src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/Resolve.java test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out
diffstat 4 files changed, 10 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri May 09 15:37:12 2014 -0700
+++ b/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/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri May 09 15:37:12 2014 -0700
+++ b/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/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java	Fri May 09 15:37:12 2014 -0700
+++ b/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/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out	Fri May 09 15:37:12 2014 -0700
+++ b/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