Merge
This commit is contained in:
commit
fbb54463fe
langtools
src/jdk.compiler/share/classes/com/sun/tools/javac/comp
test/tools/javac
annotations/typeAnnotations/failures
generics/inference/8078024
@ -4140,12 +4140,7 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
public void visitAnnotatedType(JCAnnotatedType tree) {
|
||||
attribAnnotationTypes(tree.annotations, env);
|
||||
JCExpression underlyingTypeTree = tree.getUnderlyingType();
|
||||
Type underlyingType = attribTree(underlyingTypeTree, env,
|
||||
new ResultInfo(KindSelector.TYP_PCK, Type.noType));
|
||||
if (!chk.checkAnnotableType(underlyingType, tree.annotations, underlyingTypeTree.pos())) {
|
||||
underlyingType = underlyingTypeTree.type = syms.errType;
|
||||
}
|
||||
Type underlyingType = attribType(tree.underlyingType, env);
|
||||
Type annotatedType = underlyingType.annotatedType(Annotations.TO_BE_SET);
|
||||
|
||||
if (!env.info.isNewClass)
|
||||
@ -4636,7 +4631,16 @@ public class Attr extends JCTree.Visitor {
|
||||
}
|
||||
} else if (enclTr.hasTag(ANNOTATED_TYPE)) {
|
||||
JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr;
|
||||
if (!chk.checkAnnotableType(enclTy, at.getAnnotations(), at.underlyingType.pos())) {
|
||||
if (enclTy == null || enclTy.hasTag(NONE)) {
|
||||
if (at.getAnnotations().size() == 1) {
|
||||
log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute);
|
||||
} else {
|
||||
ListBuffer<Attribute.Compound> comps = new ListBuffer<>();
|
||||
for (JCAnnotation an : at.getAnnotations()) {
|
||||
comps.add(an.attribute);
|
||||
}
|
||||
log.error(at.underlyingType.pos(), "cant.type.annotate.scoping", comps.toList());
|
||||
}
|
||||
repeat = false;
|
||||
}
|
||||
enclTr = at.underlyingType;
|
||||
|
@ -63,8 +63,6 @@ import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
|
||||
import static com.sun.tools.javac.code.TypeTag.*;
|
||||
import static com.sun.tools.javac.code.TypeTag.WILDCARD;
|
||||
|
||||
import static com.sun.tools.javac.resources.CompilerProperties.Errors.CantTypeAnnotateScoping;
|
||||
import static com.sun.tools.javac.resources.CompilerProperties.Errors.CantTypeAnnotateScoping1;
|
||||
import static com.sun.tools.javac.tree.JCTree.Tag.*;
|
||||
|
||||
/** Type checking helper class for the attribution phase.
|
||||
@ -2694,29 +2692,6 @@ public class Check {
|
||||
* Check annotations
|
||||
**************************************************************************/
|
||||
|
||||
/** Verify that a component of a qualified type name being type annotated
|
||||
* can indeed be legally be annotated. For example, package names and type
|
||||
* names used to access static members cannot be annotated.
|
||||
*
|
||||
* @param typeComponent the component of the qualified name being annotated
|
||||
* @param annotations the annotations
|
||||
* @param pos diagnostic position
|
||||
* @return true if all is swell, false otherwise.
|
||||
*/
|
||||
boolean checkAnnotableType(Type typeComponent, List<JCAnnotation> annotations, DiagnosticPosition pos) {
|
||||
if (typeComponent == null || typeComponent.hasTag(PACKAGE) || typeComponent.hasTag(NONE)) {
|
||||
ListBuffer<Symbol> lb = new ListBuffer<>();
|
||||
for (JCAnnotation annotation : annotations) {
|
||||
lb.append(annotation.annotationType.type.tsym);
|
||||
}
|
||||
List<Symbol> symbols = lb.toList();
|
||||
log.error(pos,
|
||||
symbols.size() > 1 ? CantTypeAnnotateScoping(symbols)
|
||||
: CantTypeAnnotateScoping1(symbols.get(0)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Recursively validate annotations values
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8026564 8074346
|
||||
* @bug 8026564
|
||||
* @summary The parts of a fully-qualified type can't be annotated.
|
||||
* @author Werner Dietl
|
||||
* @ignore 8057679 clarify error messages trying to annotate scoping
|
||||
* @compile/fail/ref=CantAnnotatePackages.out -XDrawDiagnostics CantAnnotatePackages.java
|
||||
*/
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
@ -21,8 +21,6 @@ class CantAnnotatePackages {
|
||||
java. @TA lang.Object of3;
|
||||
List<java. @TA lang.Object> of4;
|
||||
|
||||
List<@CantAnnotatePackages_TB java.lang.Object> of5; // test that we do reasonable things for missing types.
|
||||
|
||||
// TODO: also note the order of error messages.
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
CantAnnotatePackages.java:20:14: compiler.err.cant.type.annotate.scoping.1: TA
|
||||
CantAnnotatePackages.java:21:9: compiler.err.cant.type.annotate.scoping.1: TA
|
||||
CantAnnotatePackages.java:22:14: compiler.err.cant.type.annotate.scoping.1: TA
|
||||
CantAnnotatePackages.java:24:11: compiler.err.cant.resolve.location: kindname.class, CantAnnotatePackages_TB, , , (compiler.misc.location: kindname.class, CantAnnotatePackages, null)
|
||||
CantAnnotatePackages.java:24:35: compiler.err.cant.type.annotate.scoping.1: CantAnnotatePackages_TB
|
||||
CantAnnotatePackages.java:15:18: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
6 errors
|
||||
CantAnnotatePackages.java:14:13: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotatePackages.java:19:18: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotatePackages.java:20:19: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotatePackages.java:21:24: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
4 errors
|
||||
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8074346
|
||||
* @author sadayapalam
|
||||
* @summary Test that type annotation on a qualified type doesn't cause spurious 'cannot find symbol' errors
|
||||
* @compile/fail/ref=T8074346.out -XDrawDiagnostics T8074346.java
|
||||
*/
|
||||
|
||||
abstract class T8074346 implements
|
||||
@T8074346_TA @T8074346_TB java.util.Map<@T8074346_TA java.lang.String, java.lang.@T8074346_TA String>,
|
||||
java.util.@T8074346_TA List {
|
||||
}
|
||||
|
||||
@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
|
||||
@interface T8074346_TA { }
|
||||
|
||||
@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
|
||||
@interface T8074346_TB { }
|
@ -1,3 +0,0 @@
|
||||
T8074346.java:10:35: compiler.err.cant.type.annotate.scoping: T8074346_TA,T8074346_TB
|
||||
T8074346.java:10:62: compiler.err.cant.type.annotate.scoping.1: T8074346_TA
|
||||
2 errors
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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 8078024
|
||||
* @summary before the patch for JDK-8078024 this code wasn't accepted by the compiler. After the
|
||||
* mentioned patch the second method is selected as applicable and the code is accepted.
|
||||
* @compile T8078024.java
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
class T8078024 {
|
||||
public static <A> List<List<A>> cartesianProduct(List<? extends A>... lists) {
|
||||
return cartesianProduct(Arrays.asList(lists));
|
||||
}
|
||||
|
||||
public static <B> List<List<B>> cartesianProduct(List<? extends List<? extends B>> lists) {
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user