Merge
This commit is contained in:
commit
01af1b8223
@ -640,6 +640,10 @@ public class Type implements PrimitiveType {
|
||||
return typarams_field;
|
||||
}
|
||||
|
||||
public boolean hasErasedSupertypes() {
|
||||
return isRaw();
|
||||
}
|
||||
|
||||
public Type getEnclosingType() {
|
||||
return outer_field;
|
||||
}
|
||||
@ -711,6 +715,17 @@ public class Type implements PrimitiveType {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ErasedClassType extends ClassType {
|
||||
public ErasedClassType(Type outer, TypeSymbol tsym) {
|
||||
super(outer, List.<Type>nil(), tsym);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasErasedSupertypes() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ArrayType extends Type
|
||||
implements javax.lang.model.type.ArrayType {
|
||||
|
||||
|
@ -1499,47 +1499,68 @@ public class Types {
|
||||
* type parameters in t are deleted.
|
||||
*/
|
||||
public Type erasure(Type t) {
|
||||
return erasure(t, false);
|
||||
}
|
||||
//where
|
||||
private Type erasure(Type t, boolean recurse) {
|
||||
if (t.tag <= lastBaseTag)
|
||||
return t; /* fast special case */
|
||||
else
|
||||
return erasure.visit(t);
|
||||
return erasure.visit(t, recurse);
|
||||
}
|
||||
// where
|
||||
private UnaryVisitor<Type> erasure = new UnaryVisitor<Type>() {
|
||||
public Type visitType(Type t, Void ignored) {
|
||||
private SimpleVisitor<Type, Boolean> erasure = new SimpleVisitor<Type, Boolean>() {
|
||||
public Type visitType(Type t, Boolean recurse) {
|
||||
if (t.tag <= lastBaseTag)
|
||||
return t; /*fast special case*/
|
||||
else
|
||||
return t.map(erasureFun);
|
||||
return t.map(recurse ? erasureRecFun : erasureFun);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitWildcardType(WildcardType t, Void ignored) {
|
||||
return erasure(upperBound(t));
|
||||
public Type visitWildcardType(WildcardType t, Boolean recurse) {
|
||||
return erasure(upperBound(t), recurse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitClassType(ClassType t, Void ignored) {
|
||||
return t.tsym.erasure(Types.this);
|
||||
public Type visitClassType(ClassType t, Boolean recurse) {
|
||||
Type erased = t.tsym.erasure(Types.this);
|
||||
if (recurse) {
|
||||
erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym);
|
||||
}
|
||||
return erased;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitTypeVar(TypeVar t, Void ignored) {
|
||||
return erasure(t.bound);
|
||||
public Type visitTypeVar(TypeVar t, Boolean recurse) {
|
||||
return erasure(t.bound, recurse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitErrorType(ErrorType t, Void ignored) {
|
||||
public Type visitErrorType(ErrorType t, Boolean recurse) {
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
private Mapping erasureFun = new Mapping ("erasure") {
|
||||
public Type apply(Type t) { return erasure(t); }
|
||||
};
|
||||
|
||||
private Mapping erasureRecFun = new Mapping ("erasureRecursive") {
|
||||
public Type apply(Type t) { return erasureRecursive(t); }
|
||||
};
|
||||
|
||||
public List<Type> erasure(List<Type> ts) {
|
||||
return Type.map(ts, erasureFun);
|
||||
}
|
||||
|
||||
public Type erasureRecursive(Type t) {
|
||||
return erasure(t, true);
|
||||
}
|
||||
|
||||
public List<Type> erasureRecursive(List<Type> ts) {
|
||||
return Type.map(ts, erasureRecFun);
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="makeCompoundType">
|
||||
@ -1626,15 +1647,14 @@ public class Types {
|
||||
if (t.supertype_field == null) {
|
||||
List<Type> actuals = classBound(t).allparams();
|
||||
List<Type> formals = t.tsym.type.allparams();
|
||||
if (actuals.isEmpty()) {
|
||||
if (formals.isEmpty())
|
||||
// Should not happen. See comments below in interfaces
|
||||
t.supertype_field = supertype;
|
||||
else
|
||||
t.supertype_field = erasure(supertype);
|
||||
} else {
|
||||
if (t.hasErasedSupertypes()) {
|
||||
t.supertype_field = erasureRecursive(supertype);
|
||||
} else if (formals.nonEmpty()) {
|
||||
t.supertype_field = subst(supertype, formals, actuals);
|
||||
}
|
||||
else {
|
||||
t.supertype_field = supertype;
|
||||
}
|
||||
}
|
||||
}
|
||||
return t.supertype_field;
|
||||
@ -1708,18 +1728,15 @@ public class Types {
|
||||
assert t != t.tsym.type : t.toString();
|
||||
List<Type> actuals = t.allparams();
|
||||
List<Type> formals = t.tsym.type.allparams();
|
||||
if (actuals.isEmpty()) {
|
||||
if (formals.isEmpty()) {
|
||||
// In this case t is not generic (nor raw).
|
||||
// So this should not happen.
|
||||
t.interfaces_field = interfaces;
|
||||
} else {
|
||||
t.interfaces_field = erasure(interfaces);
|
||||
}
|
||||
} else {
|
||||
if (t.hasErasedSupertypes()) {
|
||||
t.interfaces_field = erasureRecursive(interfaces);
|
||||
} else if (formals.nonEmpty()) {
|
||||
t.interfaces_field =
|
||||
upperBounds(subst(interfaces, formals, actuals));
|
||||
}
|
||||
else {
|
||||
t.interfaces_field = interfaces;
|
||||
}
|
||||
}
|
||||
}
|
||||
return t.interfaces_field;
|
||||
|
@ -1810,7 +1810,7 @@ public class Attr extends JCTree.Visitor {
|
||||
chk.earlyRefError(tree.pos(), sym.kind == VAR ? sym : thisSym(tree.pos(), env));
|
||||
}
|
||||
Env<AttrContext> env1 = env;
|
||||
if (sym.kind != ERR && sym.owner != null && sym.owner != env1.enclClass.sym) {
|
||||
if (sym.kind != ERR && sym.kind != TYP && sym.owner != null && sym.owner != env1.enclClass.sym) {
|
||||
// If the found symbol is inaccessible, then it is
|
||||
// accessed through an enclosing instance. Locate this
|
||||
// enclosing instance:
|
||||
@ -1878,8 +1878,10 @@ public class Attr extends JCTree.Visitor {
|
||||
boolean varArgs = env.info.varArgs;
|
||||
tree.sym = sym;
|
||||
|
||||
if (site.tag == TYPEVAR && !isType(sym) && sym.kind != ERR)
|
||||
site = capture(site.getUpperBound());
|
||||
if (site.tag == TYPEVAR && !isType(sym) && sym.kind != ERR) {
|
||||
while (site.tag == TYPEVAR) site = site.getUpperBound();
|
||||
site = capture(site);
|
||||
}
|
||||
|
||||
// If that symbol is a variable, ...
|
||||
if (sym.kind == VAR) {
|
||||
|
@ -1247,7 +1247,7 @@ public class Check {
|
||||
for (Type t2 = sup;
|
||||
t2.tag == CLASS;
|
||||
t2 = types.supertype(t2)) {
|
||||
for (Scope.Entry e2 = t1.tsym.members().lookup(s1.name);
|
||||
for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name);
|
||||
e2.scope != null;
|
||||
e2 = e2.next()) {
|
||||
Symbol s2 = e2.sym;
|
||||
@ -1394,6 +1394,16 @@ public class Check {
|
||||
while (e.scope != null) {
|
||||
if (m.overrides(e.sym, origin, types, false))
|
||||
checkOverride(tree, m, (MethodSymbol)e.sym, origin);
|
||||
else if (e.sym.isInheritedIn(origin, types) && !m.isConstructor()) {
|
||||
Type er1 = m.erasure(types);
|
||||
Type er2 = e.sym.erasure(types);
|
||||
if (types.isSameType(er1,er2)) {
|
||||
log.error(TreeInfo.diagnosticPositionFor(m, tree),
|
||||
"name.clash.same.erasure.no.override",
|
||||
m, m.location(),
|
||||
e.sym, e.sym.location());
|
||||
}
|
||||
}
|
||||
e = e.next();
|
||||
}
|
||||
}
|
||||
|
@ -690,13 +690,15 @@ public class TransTypes extends TreeTranslator {
|
||||
|
||||
public void visitSelect(JCFieldAccess tree) {
|
||||
Type t = tree.selected.type;
|
||||
if (t.isCompound() || (t.tag == TYPEVAR && t.getUpperBound().isCompound())) {
|
||||
while (t.tag == TYPEVAR)
|
||||
t = t.getUpperBound();
|
||||
if (t.isCompound()) {
|
||||
if ((tree.sym.flags() & IPROXY) != 0) {
|
||||
tree.sym = ((MethodSymbol)tree.sym).
|
||||
implemented((TypeSymbol)tree.sym.owner, types);
|
||||
}
|
||||
tree.selected = cast(
|
||||
translate(tree.selected, erasure(t)),
|
||||
translate(tree.selected, erasure(tree.selected.type)),
|
||||
erasure(tree.sym.owner.type));
|
||||
} else
|
||||
tree.selected = translate(tree.selected, erasure(t));
|
||||
|
@ -1006,7 +1006,10 @@ public class Parser {
|
||||
break loop;
|
||||
case DOT:
|
||||
S.nextToken();
|
||||
int oldmode = mode;
|
||||
mode &= ~NOPARAMS;
|
||||
typeArgs = typeArgumentsOpt(EXPR);
|
||||
mode = oldmode;
|
||||
if ((mode & EXPR) != 0) {
|
||||
switch (S.token()) {
|
||||
case CLASS:
|
||||
|
41
langtools/test/tools/javac/generics/5009937/T5009937.java
Normal file
41
langtools/test/tools/javac/generics/5009937/T5009937.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 5009937
|
||||
* @summary hiding versus generics versus binary compatibility
|
||||
* @author Maurizio Cimadamore
|
||||
*
|
||||
* @compile/fail/ref=T5009937.out -XDstdout -XDrawDiagnostics T5009937.java
|
||||
*/
|
||||
|
||||
public class T5009937<X> {
|
||||
static class A {
|
||||
static void m(T5009937<String> l) {}
|
||||
}
|
||||
|
||||
static class B extends A {
|
||||
static void m(T5009937<Integer> l) {}
|
||||
}
|
||||
}
|
2
langtools/test/tools/javac/generics/5009937/T5009937.out
Normal file
2
langtools/test/tools/javac/generics/5009937/T5009937.out
Normal file
@ -0,0 +1,2 @@
|
||||
T5009937.java:39:21: compiler.err.name.clash.same.erasure.no.override: m(T5009937<java.lang.Integer>), T5009937.B, m(T5009937<java.lang.String>), T5009937.A
|
||||
1 error
|
66
langtools/test/tools/javac/generics/6531075/T6531075.java
Normal file
66
langtools/test/tools/javac/generics/6531075/T6531075.java
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6531075
|
||||
*
|
||||
* @summary Missing synthetic casts when accessing fields/methods of intersection types including type variables
|
||||
* @author Maurizio Cimadamore
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class T6531075 {
|
||||
|
||||
static class A {
|
||||
void a() {}
|
||||
}
|
||||
|
||||
static interface I{
|
||||
void i();
|
||||
}
|
||||
|
||||
static class E extends A implements I{
|
||||
public void i() {}
|
||||
}
|
||||
|
||||
static class C<W extends A & I, T extends W>{
|
||||
T t;
|
||||
W w;
|
||||
C(W w, T t) {
|
||||
this.w = w;
|
||||
this.t = t;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
C<E,E> c = new C<E,E>(new E(), new E());
|
||||
testMemberMethods(c);
|
||||
}
|
||||
|
||||
static void testMemberMethods(C<?, ?> arg) {
|
||||
arg.t.a();
|
||||
arg.t.i();
|
||||
}
|
||||
}
|
45
langtools/test/tools/javac/generics/Casting5.java
Normal file
45
langtools/test/tools/javac/generics/Casting5.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6559182
|
||||
* @summary Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
|
||||
* @author Maurizio Cimadamore
|
||||
*
|
||||
* @compile Casting5.java
|
||||
*/
|
||||
|
||||
class Casting5 {
|
||||
static interface Super<P> {}
|
||||
static class Y implements Super<Integer>{}
|
||||
static interface X extends Super<Double>{}
|
||||
static class S<L> extends Y {}
|
||||
static interface T<L> extends X {}
|
||||
|
||||
public static void main(String... args) {
|
||||
S s = null; // same if I use S<Byte>
|
||||
T t = null; // same if I use T<Byte>
|
||||
t = (T) s;
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4984158
|
||||
* @summary two inherited methods with same signature
|
||||
* @author gafter
|
||||
* @author gafter, Maurizio Cimadamore
|
||||
*
|
||||
* @compile/fail -source 1.5 InheritanceConflict.java
|
||||
*/
|
||||
@ -34,8 +34,11 @@ package inheritance.conflict;
|
||||
|
||||
class A<T> {
|
||||
void f(String s) {}
|
||||
}
|
||||
|
||||
class B<T> extends A<T> {
|
||||
void f(T t) {}
|
||||
}
|
||||
|
||||
class B extends A<String> {
|
||||
class C extends B<String> {
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4984158
|
||||
* @summary two inherited methods with same signature
|
||||
* @author gafter
|
||||
* @author gafter, Maurizio Cimadamore
|
||||
*
|
||||
* @compile -source 1.5 InheritanceConflict2.java
|
||||
*/
|
||||
@ -34,9 +34,12 @@ package inheritance.conflict2;
|
||||
|
||||
class A<T> {
|
||||
void f(String s) {}
|
||||
}
|
||||
|
||||
class B<T> extends A<T> {
|
||||
void f(T t) {}
|
||||
}
|
||||
|
||||
class B extends A<String> {
|
||||
class C extends B<String> {
|
||||
void f(String s) {}
|
||||
}
|
||||
|
41
langtools/test/tools/javac/generics/T6481655.java
Normal file
41
langtools/test/tools/javac/generics/T6481655.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6481655
|
||||
* @summary Parser confused by combination of parens and explicit type args
|
||||
* @author Maurizio Cimadamore
|
||||
*/
|
||||
|
||||
public class T6481655 {
|
||||
|
||||
public static <T> T getT(T t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
public static void main(String... s) {
|
||||
T6481655.<String>getT("");
|
||||
(T6481655.<String>getT("")).getClass();
|
||||
}
|
||||
}
|
44
langtools/test/tools/javac/generics/T6657499.java
Normal file
44
langtools/test/tools/javac/generics/T6657499.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
*
|
||||
* @bug 6657499
|
||||
* @summary generics: javac 1.6.0 fails to compile class with inner class
|
||||
* @author Maurizio Cimadamore
|
||||
*
|
||||
*/
|
||||
|
||||
public class T6657499<T> {
|
||||
T t;
|
||||
public T test() {
|
||||
class Local {private T t;};
|
||||
class Local2 {T m() {return t;}};
|
||||
T t3 = new Local().t;
|
||||
return new Local2().m();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
String s = new T6657499<String>().test();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6365166
|
||||
* @summary javac (generic) unable to resolve methods
|
||||
* @author Maurizio Cimadamore
|
||||
*
|
||||
* @compile T6365166.java
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class T6365166 {
|
||||
static <A> void add(List<? super A> l, List<A> la) {
|
||||
l.addAll(la); //doesn't compile - but it should
|
||||
}
|
||||
}
|
||||
|
@ -29,18 +29,18 @@
|
||||
*/
|
||||
public class T6611449<S> {
|
||||
|
||||
T6611449() {this(1);}
|
||||
|
||||
<T extends S> T6611449(T t1) {this(t1, 1);}
|
||||
<T extends S> T6611449(T t1) {}
|
||||
|
||||
<T extends S> T6611449(T t1, T t2) {}
|
||||
|
||||
<T extends S> void m(T t1) {}
|
||||
<T extends S> void m1(T t1) {}
|
||||
|
||||
<T extends S> void m(T t1, T t2) {}
|
||||
<T extends S> void m2(T t1, T t2) {}
|
||||
|
||||
void test() {
|
||||
new T6611449<S>(1);
|
||||
new T6611449<S>(1, 1); //internal error: lub is erroneously applied to primitive types
|
||||
m1(1);
|
||||
m2(1, 1);
|
||||
m2(1, 1); //internal error: lub is erroneously applied to primitive types
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
T6611449.java:32:17: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int), , (- compiler.misc.kindname.class), T6611449<S>
|
||||
T6611449.java:34:35: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (T,int), , (- compiler.misc.kindname.class), T6611449<S>
|
||||
T6611449.java:43:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m1, (int), , (- compiler.misc.kindname.class), T6611449<S>
|
||||
T6611449.java:44:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m2, (int,int), , (- compiler.misc.kindname.class), T6611449<S>
|
||||
T6611449.java:41:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int), , (- compiler.misc.kindname.class), T6611449<S>
|
||||
T6611449.java:42:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int,int), , (- compiler.misc.kindname.class), T6611449<S>
|
||||
T6611449.java:43:9: compiler.err.cant.apply.symbol: <T>m1(T), T6611449<S>, , int, null
|
||||
T6611449.java:44:9: compiler.err.cant.apply.symbol: <T>m2(T,T), T6611449<S>, , int,int, null
|
||||
4 errors
|
||||
|
44
langtools/test/tools/javac/generics/wildcards/T6450290.java
Normal file
44
langtools/test/tools/javac/generics/wildcards/T6450290.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2004-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6450290
|
||||
* @summary Capture of nested wildcards causes type error
|
||||
* @author Maurizio Cimadamore
|
||||
* @compile/fail T6450290.java
|
||||
*/
|
||||
|
||||
public class T6450290 {
|
||||
static class Box<X extends Box<?,?>, T extends X> {
|
||||
T value;
|
||||
Box<X, T> same;
|
||||
}
|
||||
|
||||
static class A extends Box<A,A> {}
|
||||
static class B extends Box<B,B> {}
|
||||
public static void main(String[] args) {
|
||||
Box<?,?> b = new Box<Box<A,A>,Box<A,A>>();
|
||||
b.value.same = new Box<B,B>(); //javac misses this bad assignment
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user