release/icedtea6-1.8

view patches/openjdk/6650759-missing_inference.patch @ 2087:eab926d1eb04

Fix test output for 6638712.

2010-09-17 Andrew John Hughes <ahughes@redhat.com>

* patches/openjdk/6638712-wildcard_types.patch:
Fix copyrights (from 6875336) and test output.
* patches/openjdk/6650759-missing_inference.patch,
Remove test output changes already incorporated in
6875336.
author Andrew John Hughes <ahughes@redhat.com>
date Fri Sep 17 15:01:17 2010 +0100 (2010-09-17)
parents d3e0fe2c10b2
children
line source
1 diff -Nru openjdk.orig/langtools/src/share/classes/com/sun/tools/javac/code/Type.java openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Type.java
2 --- openjdk.orig/langtools/src/share/classes/com/sun/tools/javac/code/Type.java 2010-09-09 20:03:34.000000000 +0100
3 +++ openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Type.java 2010-09-09 20:24:56.236744893 +0100
4 @@ -1063,7 +1063,7 @@
6 /**
7 * Replaces this ForAll's typevars with a set of concrete Java types
8 - * and returns the instantiated generic type. Subclasses might override
9 + * and returns the instantiated generic type. Subclasses should override
10 * in order to check that the list of types is a valid instantiation
11 * of the ForAll's typevars.
12 *
13 @@ -1076,6 +1076,42 @@
14 return types.subst(qtype, tvars, actuals);
15 }
17 + /**
18 + * Kind of type-constraint derived during type inference
19 + */
20 + public enum ConstraintKind {
21 + /**
22 + * upper bound constraint (a type variable must be instantiated
23 + * with a type T, where T is a subtype of all the types specified by
24 + * its EXTENDS constraints).
25 + */
26 + EXTENDS,
27 + /**
28 + * lower bound constraint (a type variable must be instantiated
29 + * with a type T, where T is a supertype of all the types specified by
30 + * its SUPER constraints).
31 + */
32 + SUPER,
33 + /**
34 + * equality constraint (a type variable must be instantiated to the type
35 + * specified by its EQUAL constraint.
36 + */
37 + EQUAL;
38 + }
39 +
40 + /**
41 + * Get the type-constraints of a given kind for a given type-variable of
42 + * this ForAll type. Subclasses should override in order to return more
43 + * accurate sets of constraints.
44 + *
45 + * @param tv the type-variable for which the constraint is to be retrieved
46 + * @param ck the constraint kind to be retrieved
47 + * @return the list of types specified by the selected constraint
48 + */
49 + public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
50 + return List.nil();
51 + }
52 +
53 public Type map(Mapping f) {
54 return f.apply(qtype);
55 }
56 diff -Nru openjdk.orig/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java
57 --- openjdk.orig/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java 2010-09-09 20:03:34.000000000 +0100
58 +++ openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java 2010-09-09 20:25:15.752817376 +0100
59 @@ -29,6 +29,7 @@
60 import com.sun.tools.javac.util.List;
61 import com.sun.tools.javac.code.*;
62 import com.sun.tools.javac.code.Type.*;
63 +import com.sun.tools.javac.code.Type.ForAll.ConstraintKind;
64 import com.sun.tools.javac.code.Symbol.*;
66 import static com.sun.tools.javac.code.Flags.*;
67 @@ -51,6 +52,7 @@
69 Symtab syms;
70 Types types;
71 + Check chk;
72 Resolve rs;
74 public static Infer instance(Context context) {
75 @@ -65,6 +67,7 @@
76 syms = Symtab.instance(context);
77 types = Types.instance(context);
78 rs = Resolve.instance(context);
79 + chk = Check.instance(context);
80 }
82 public static class InferenceException extends RuntimeException {
83 @@ -260,14 +263,19 @@
84 Warner warn) throws InferenceException {
85 List<Type> undetvars = Type.map(that.tvars, fromTypeVarFun);
86 for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
87 - UndetVar v = (UndetVar) l.head;
88 + UndetVar uv = (UndetVar) l.head;
89 + TypeVar tv = (TypeVar)uv.qtype;
90 ListBuffer<Type> hibounds = new ListBuffer<Type>();
91 - for (List<Type> l1 = types.getBounds((TypeVar) v.qtype); l1.nonEmpty(); l1 = l1.tail) {
92 - if (!l1.head.containsSome(that.tvars)) {
93 - hibounds.append(l1.head);
94 + for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS).prependList(types.getBounds(tv))) {
95 + if (!t.containsSome(that.tvars) && t.tag != BOT) {
96 + hibounds.append(t);
97 }
98 }
99 - v.hibounds = hibounds.toList();
100 + List<Type> inst = that.getConstraints(tv, ConstraintKind.EQUAL);
101 + if (inst.nonEmpty() && inst.head.tag != BOT) {
102 + uv.inst = inst.head;
103 + }
104 + uv.hibounds = hibounds.toList();
105 }
106 Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
107 if (!types.isSubtype(qtype1, to)) {
108 @@ -283,7 +291,7 @@
109 List<Type> targs = Type.map(undetvars, getInstFun);
110 targs = types.subst(targs, that.tvars, targs);
111 checkWithinBounds(that.tvars, targs, warn);
112 - return that.inst(targs, types);
113 + return chk.checkType(warn.pos(), that.inst(targs, types), to);
114 }
116 /** Instantiate method type `mt' by finding instantiations of
117 @@ -359,6 +367,9 @@
118 /** Type variables instantiated to bottom */
119 ListBuffer<Type> restvars = new ListBuffer<Type>();
121 + /** Undet vars instantiated to bottom */
122 + final ListBuffer<Type> restundet = new ListBuffer<Type>();
123 +
124 /** Instantiated types or TypeVars if under-constrained */
125 ListBuffer<Type> insttypes = new ListBuffer<Type>();
127 @@ -369,6 +380,7 @@
128 UndetVar uv = (UndetVar)t;
129 if (uv.inst.tag == BOT) {
130 restvars.append(uv.qtype);
131 + restundet.append(uv);
132 insttypes.append(uv.qtype);
133 undettypes.append(uv);
134 uv.inst = null;
135 @@ -389,17 +401,32 @@
136 final MethodType mt2 = new MethodType(mt.argtypes, null, mt.thrown, syms.methodClass);
137 mt2.restype = new ForAll(restvars.toList(), mt.restype) {
138 @Override
139 + public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
140 + for (Type t : restundet.toList()) {
141 + UndetVar uv = (UndetVar)t;
142 + if (uv.qtype == tv) {
143 + switch (ck) {
144 + case EXTENDS: return uv.hibounds;
145 + case SUPER: return uv.lobounds;
146 + case EQUAL: return uv.inst != null ? List.of(uv.inst) : List.<Type>nil();
147 + }
148 + }
149 + }
150 + return List.nil();
151 + }
152 +
153 + @Override
154 public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
155 List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
156 - if (!rs.argumentsAcceptable(capturedArgs, formals,
157 + if (!rs.argumentsAcceptable(capturedArgs, formals,
158 allowBoxing, useVarargs, warn)) {
159 // inferred method is not applicable
160 throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes);
161 - }
162 - // check that inferred bounds conform to their bounds
163 - checkWithinBounds(all_tvars,
164 + }
165 + // check that inferred bounds conform to their bounds
166 + checkWithinBounds(all_tvars,
167 types.subst(inferredTypes, tvars, inferred), warn);
168 - return super.inst(inferred, types);
169 + return super.inst(inferred, types);
170 }};
171 return mt2;
172 }
173 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6302954/T6476073.java openjdk/langtools/test/tools/javac/generics/inference/6302954/T6476073.java
174 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6302954/T6476073.java 2010-09-09 20:03:34.000000000 +0100
175 +++ openjdk/langtools/test/tools/javac/generics/inference/6302954/T6476073.java 2010-09-09 20:24:56.236744893 +0100
176 @@ -25,7 +25,6 @@
177 * @test
178 * @bug 6476073
179 * @summary Capture using super wildcard of type variables doesn't work
180 - * @ignore awaiting for 6650759 (see bug report for a detailed evaluation)
181 * @compile T6476073.java
182 */
184 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759a.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759a.java
185 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759a.java 1970-01-01 01:00:00.000000000 +0100
186 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759a.java 2010-09-09 20:24:56.248744934 +0100
187 @@ -0,0 +1,45 @@
188 +/*
189 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
190 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
191 + *
192 + * This code is free software; you can redistribute it and/or modify it
193 + * under the terms of the GNU General Public License version 2 only, as
194 + * published by the Free Software Foundation.
195 + *
196 + * This code is distributed in the hope that it will be useful, but WITHOUT
197 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
198 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
199 + * version 2 for more details (a copy is included in the LICENSE file that
200 + * accompanied this code).
201 + *
202 + * You should have received a copy of the GNU General Public License version
203 + * 2 along with this work; if not, write to the Free Software Foundation,
204 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
205 + *
206 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
207 + * CA 95054 USA or visit www.sun.com if you need additional information or
208 + * have any questions.
209 + */
210 +
211 +/*
212 + * @test
213 + * @bug 6650759
214 + * @author mcimadamore
215 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
216 + * @compile T6650759a.java
217 + */
218 +
219 +class T6650759a {
220 +
221 + public static interface Interface<T> { }
222 + public static class IntegerInterface implements Interface<Integer> { }
223 +
224 + <I extends Interface<T>, T> T getGenericValue(I test) { return null; }
225 +
226 + void testSet(Integer test) { }
227 +
228 + void test() {
229 + Integer test = getGenericValue(new IntegerInterface());
230 + testSet(getGenericValue(new IntegerInterface()));
231 + }
232 +}
233 \ No newline at end of file
234 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759b.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759b.java
235 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759b.java 1970-01-01 01:00:00.000000000 +0100
236 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759b.java 2010-09-09 20:24:56.248744934 +0100
237 @@ -0,0 +1,52 @@
238 +/*
239 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
240 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
241 + *
242 + * This code is free software; you can redistribute it and/or modify it
243 + * under the terms of the GNU General Public License version 2 only, as
244 + * published by the Free Software Foundation.
245 + *
246 + * This code is distributed in the hope that it will be useful, but WITHOUT
247 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
248 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
249 + * version 2 for more details (a copy is included in the LICENSE file that
250 + * accompanied this code).
251 + *
252 + * You should have received a copy of the GNU General Public License version
253 + * 2 along with this work; if not, write to the Free Software Foundation,
254 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
255 + *
256 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
257 + * CA 95054 USA or visit www.sun.com if you need additional information or
258 + * have any questions.
259 + */
260 +
261 +/*
262 + * @test
263 + * @bug 6650759
264 + * @author mcimadamore
265 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
266 + * @compile T6650759b.java
267 + */
268 +
269 +public class T6650759b {
270 +
271 + interface A<X extends A<X, Y>, Y extends B<X>> {}
272 +
273 + static class B<X extends A<X, ?>> {}
274 +
275 + interface C<X extends A<X, Y>, Y extends B<X>> {}
276 +
277 + interface D<X extends A<X, Y>, Y extends B<X>> {}
278 +
279 + static class E<X extends A<X, Y>, Y extends B<X>, W extends C<X, Y>> implements D<X, Y> {
280 +
281 + static <X extends A<X, Y>, Y extends B<X>, W extends C<X, Y>> D<X, Y> of(W w) {
282 + return null;
283 + }
284 + }
285 +
286 + <X extends A<X, Y>, Y extends B<X>, W extends C<X, Y>, Z extends D<X, Y>> Z test(W w) {
287 + return (Z) E.of(w);
288 + }
289 +}
290 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759c.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759c.java
291 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759c.java 1970-01-01 01:00:00.000000000 +0100
292 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759c.java 2010-09-09 20:24:56.248744934 +0100
293 @@ -0,0 +1,49 @@
294 +/*
295 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
296 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
297 + *
298 + * This code is free software; you can redistribute it and/or modify it
299 + * under the terms of the GNU General Public License version 2 only, as
300 + * published by the Free Software Foundation.
301 + *
302 + * This code is distributed in the hope that it will be useful, but WITHOUT
303 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
304 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
305 + * version 2 for more details (a copy is included in the LICENSE file that
306 + * accompanied this code).
307 + *
308 + * You should have received a copy of the GNU General Public License version
309 + * 2 along with this work; if not, write to the Free Software Foundation,
310 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
311 + *
312 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
313 + * CA 95054 USA or visit www.sun.com if you need additional information or
314 + * have any questions.
315 + */
316 +
317 +/*
318 + * @test
319 + * @bug 6650759
320 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
321 + * @compile T6650759c.java
322 + */
323 +
324 +import java.util.Collection;
325 +import java.util.Collections;
326 +
327 +public class T6650759c {
328 +
329 + static interface A {}
330 +
331 + static interface B<X extends A> {}
332 +
333 + static interface C<X extends A, Y extends B<X>> {}
334 +
335 + public static <T extends A, U extends B<T>> Collection<C<T,U>> get(U u) {
336 + return null;
337 + }
338 +
339 + public <T extends A, U extends B<T>> Collection<C<T,U>> test(U u) {
340 + return Collections.unmodifiableCollection(get(u));
341 + }
342 +}
343 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759d.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759d.java
344 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759d.java 1970-01-01 01:00:00.000000000 +0100
345 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759d.java 2010-09-09 20:24:56.248744934 +0100
346 @@ -0,0 +1,51 @@
347 +/*
348 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
349 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
350 + *
351 + * This code is free software; you can redistribute it and/or modify it
352 + * under the terms of the GNU General Public License version 2 only, as
353 + * published by the Free Software Foundation.
354 + *
355 + * This code is distributed in the hope that it will be useful, but WITHOUT
356 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
357 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
358 + * version 2 for more details (a copy is included in the LICENSE file that
359 + * accompanied this code).
360 + *
361 + * You should have received a copy of the GNU General Public License version
362 + * 2 along with this work; if not, write to the Free Software Foundation,
363 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
364 + *
365 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
366 + * CA 95054 USA or visit www.sun.com if you need additional information or
367 + * have any questions.
368 + */
369 +
370 +/*
371 + * @test
372 + * @bug 6650759
373 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
374 + * @compile T6650759d.java
375 + */
376 +
377 +public class T6650759d {
378 +
379 + static abstract class A<X> {
380 +
381 + static <T> A<T> m(Iterable<? extends T> elements) {
382 + return null;
383 + }
384 + }
385 +
386 + static abstract class B {}
387 +
388 + static abstract class C<X extends B> {}
389 +
390 + <U extends C<V>, V extends B> Iterable<V> get(U u) {
391 + return null;
392 + }
393 +
394 + <U extends C<V>, V extends B> void m(U u) {
395 + A<V> a = A.m(get(u));
396 + }
397 +}
398 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759e.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759e.java
399 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759e.java 1970-01-01 01:00:00.000000000 +0100
400 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759e.java 2010-09-09 20:24:56.248744934 +0100
401 @@ -0,0 +1,52 @@
402 +/*
403 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
404 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
405 + *
406 + * This code is free software; you can redistribute it and/or modify it
407 + * under the terms of the GNU General Public License version 2 only, as
408 + * published by the Free Software Foundation.
409 + *
410 + * This code is distributed in the hope that it will be useful, but WITHOUT
411 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
412 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
413 + * version 2 for more details (a copy is included in the LICENSE file that
414 + * accompanied this code).
415 + *
416 + * You should have received a copy of the GNU General Public License version
417 + * 2 along with this work; if not, write to the Free Software Foundation,
418 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
419 + *
420 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
421 + * CA 95054 USA or visit www.sun.com if you need additional information or
422 + * have any questions.
423 + */
424 +
425 +/*
426 + * @test
427 + * @bug 6650759
428 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
429 + * @compile T6650759e.java
430 + */
431 +
432 +import java.util.List;
433 +
434 +public class T6650759e {
435 +
436 + static abstract class A<X extends B> {}
437 +
438 + interface B<X extends A> extends D {}
439 +
440 + static abstract class C<X extends D> {}
441 +
442 + interface D {}
443 +
444 + static abstract class E<X extends C<? extends B<?>>> {}
445 +
446 + <U extends C<V>, V extends B<W>, W extends A<V>> W m1(E<U> e) {
447 + return m2(e);
448 + }
449 +
450 + <U extends C<V>, V extends B<W>, W extends A<V>> W m2(E<U> e) {
451 + return null;
452 + }
453 +}
454 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759f.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759f.java
455 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759f.java 1970-01-01 01:00:00.000000000 +0100
456 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759f.java 2010-09-09 20:24:56.248744934 +0100
457 @@ -0,0 +1,50 @@
458 +/*
459 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
460 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
461 + *
462 + * This code is free software; you can redistribute it and/or modify it
463 + * under the terms of the GNU General Public License version 2 only, as
464 + * published by the Free Software Foundation.
465 + *
466 + * This code is distributed in the hope that it will be useful, but WITHOUT
467 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
468 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
469 + * version 2 for more details (a copy is included in the LICENSE file that
470 + * accompanied this code).
471 + *
472 + * You should have received a copy of the GNU General Public License version
473 + * 2 along with this work; if not, write to the Free Software Foundation,
474 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
475 + *
476 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
477 + * CA 95054 USA or visit www.sun.com if you need additional information or
478 + * have any questions.
479 + */
480 +
481 +/*
482 + * @test
483 + * @bug 6650759
484 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
485 + * @compile T6650759f.java
486 + */
487 +
488 +import java.util.Collections;
489 +
490 +public class T6650759f {
491 +
492 + interface A<X extends A> {}
493 +
494 + static abstract class B<X extends B> implements A<X> {}
495 +
496 + static abstract class C<X extends D> extends B<X> {}
497 +
498 + static class D extends C<D> {}
499 +
500 + <X extends B, Y extends B<X>> Iterable<X> m(Y node) {
501 + return null;
502 + }
503 +
504 + public void test(D d) {
505 + Iterable<D> ops = (true) ? Collections.singletonList(d) : m(d);
506 + }
507 +}
508 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759g.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759g.java
509 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759g.java 1970-01-01 01:00:00.000000000 +0100
510 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759g.java 2010-09-09 20:24:56.248744934 +0100
511 @@ -0,0 +1,59 @@
512 +/*
513 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
514 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
515 + *
516 + * This code is free software; you can redistribute it and/or modify it
517 + * under the terms of the GNU General Public License version 2 only, as
518 + * published by the Free Software Foundation.
519 + *
520 + * This code is distributed in the hope that it will be useful, but WITHOUT
521 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
522 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
523 + * version 2 for more details (a copy is included in the LICENSE file that
524 + * accompanied this code).
525 + *
526 + * You should have received a copy of the GNU General Public License version
527 + * 2 along with this work; if not, write to the Free Software Foundation,
528 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
529 + *
530 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
531 + * CA 95054 USA or visit www.sun.com if you need additional information or
532 + * have any questions.
533 + */
534 +
535 +/*
536 + * @test
537 + * @bug 6650759
538 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
539 + * @compile T6650759g.java
540 + */
541 +
542 +public class T6650759g {
543 +
544 + static abstract class A<X extends A<X>> {}
545 +
546 + static abstract class B<X extends A<X>> {}
547 +
548 + interface C<X, Y> {}
549 +
550 + static abstract class D<X extends A<X>, Y extends B<X>> implements C<X, Y> {}
551 +
552 + static class E extends A<E> {}
553 +
554 + static class F extends B<E> {}
555 +
556 + static void test(Iterable<E> data) {
557 + m3(m2(data, m1(F.class)));
558 + }
559 +
560 + static <X extends A<X>, Y extends B<X>> D<X, Y> m1(Class<Y> c) {
561 + return null;
562 + }
563 +
564 + static <U, V> Iterable<V> m2(Iterable<U> x1, C<? super U, ? extends V> x2) {
565 + return null;
566 + }
567 +
568 + static void m3(Iterable<F> data) {
569 + }
570 +}
571 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759h.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759h.java
572 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759h.java 1970-01-01 01:00:00.000000000 +0100
573 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759h.java 2010-09-09 20:24:56.248744934 +0100
574 @@ -0,0 +1,39 @@
575 +/*
576 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
577 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
578 + *
579 + * This code is free software; you can redistribute it and/or modify it
580 + * under the terms of the GNU General Public License version 2 only, as
581 + * published by the Free Software Foundation.
582 + *
583 + * This code is distributed in the hope that it will be useful, but WITHOUT
584 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
585 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
586 + * version 2 for more details (a copy is included in the LICENSE file that
587 + * accompanied this code).
588 + *
589 + * You should have received a copy of the GNU General Public License version
590 + * 2 along with this work; if not, write to the Free Software Foundation,
591 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
592 + *
593 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
594 + * CA 95054 USA or visit www.sun.com if you need additional information or
595 + * have any questions.
596 + */
597 +
598 +/*
599 + * @test
600 + * @bug 6650759
601 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
602 + * @compile T6650759h.java
603 + */
604 +class T6650759h<X, Y> {
605 +
606 + <A> Object m(A a, T6650759h<?, ? super A> t) {
607 + return null;
608 + }
609 +
610 + void test(T6650759h<?, Void> t) {
611 + m(null, t);
612 + }
613 +}
614 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759i.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759i.java
615 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759i.java 1970-01-01 01:00:00.000000000 +0100
616 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759i.java 2010-09-09 20:24:56.248744934 +0100
617 @@ -0,0 +1,54 @@
618 +/*
619 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
620 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
621 + *
622 + * This code is free software; you can redistribute it and/or modify it
623 + * under the terms of the GNU General Public License version 2 only, as
624 + * published by the Free Software Foundation.
625 + *
626 + * This code is distributed in the hope that it will be useful, but WITHOUT
627 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
628 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
629 + * version 2 for more details (a copy is included in the LICENSE file that
630 + * accompanied this code).
631 + *
632 + * You should have received a copy of the GNU General Public License version
633 + * 2 along with this work; if not, write to the Free Software Foundation,
634 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
635 + *
636 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
637 + * CA 95054 USA or visit www.sun.com if you need additional information or
638 + * have any questions.
639 + */
640 +
641 +/*
642 + * @test
643 + * @bug 6650759
644 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
645 + * @compile T6650759i.java
646 + */
647 +public class T6650759i {
648 +
649 + static class A<X extends A, Y extends B> {}
650 +
651 + static class B<X extends B> {}
652 +
653 + static class C<X extends A<X, Y>, Y extends B<Y>> {}
654 +
655 + static <U extends A<U, V>, V extends B<V>> Class<U> m1(U x) {
656 + return null;
657 + }
658 +
659 + static <U extends A<U, V>, V extends B<V>> U m2(Class<U> c) {
660 + return null;
661 + }
662 +
663 + static <W, U extends A<U, V>, V extends B<V>> W m3(Class<W> c1, C<U, V> c2) {
664 + return null;
665 + }
666 +
667 + static <U extends A<U, V>, V extends B<V>> void test(U u, C<U, V> c) {
668 + m2(m1(u));
669 + U res = m3(m1(u), c);
670 + }
671 +}
672 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759j.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759j.java
673 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759j.java 1970-01-01 01:00:00.000000000 +0100
674 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759j.java 2010-09-09 20:24:56.248744934 +0100
675 @@ -0,0 +1,54 @@
676 +/*
677 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
678 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
679 + *
680 + * This code is free software; you can redistribute it and/or modify it
681 + * under the terms of the GNU General Public License version 2 only, as
682 + * published by the Free Software Foundation.
683 + *
684 + * This code is distributed in the hope that it will be useful, but WITHOUT
685 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
686 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
687 + * version 2 for more details (a copy is included in the LICENSE file that
688 + * accompanied this code).
689 + *
690 + * You should have received a copy of the GNU General Public License version
691 + * 2 along with this work; if not, write to the Free Software Foundation,
692 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
693 + *
694 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
695 + * CA 95054 USA or visit www.sun.com if you need additional information or
696 + * have any questions.
697 + */
698 +
699 +/*
700 + * @test
701 + * @bug 6650759
702 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
703 + * @compile T6650759j.java
704 + */
705 +
706 +public class T6650759j {
707 +
708 + static abstract class A<X extends A<X>> {}
709 +
710 + static abstract class B<X extends B<X, Y>, Y> extends A<X> {}
711 +
712 + static abstract class C<X extends C<X, Y>, Y> extends B<X, Y> {}
713 +
714 + interface D {}
715 +
716 + static class E extends C<E, D> {}
717 +
718 + static abstract class F<X extends F<X, Y>, Y extends A<Y>> extends A<X> {}
719 +
720 + static class G extends F<G, E> {}
721 +
722 + static <X extends F<X, Y>, Y extends A<Y>> X m(Iterable<X> it) {
723 + return null;
724 + }
725 +
726 + static G test(Iterable<G> c) {
727 + return m(c);
728 + }
729 +}
730 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759k.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759k.java
731 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759k.java 1970-01-01 01:00:00.000000000 +0100
732 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759k.java 2010-09-09 20:24:56.248744935 +0100
733 @@ -0,0 +1,44 @@
734 +/*
735 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
736 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
737 + *
738 + * This code is free software; you can redistribute it and/or modify it
739 + * under the terms of the GNU General Public License version 2 only, as
740 + * published by the Free Software Foundation.
741 + *
742 + * This code is distributed in the hope that it will be useful, but WITHOUT
743 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
744 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
745 + * version 2 for more details (a copy is included in the LICENSE file that
746 + * accompanied this code).
747 + *
748 + * You should have received a copy of the GNU General Public License version
749 + * 2 along with this work; if not, write to the Free Software Foundation,
750 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
751 + *
752 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
753 + * CA 95054 USA or visit www.sun.com if you need additional information or
754 + * have any questions.
755 + */
756 +
757 +/*
758 + * @test
759 + * @bug 6650759
760 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
761 + * @compile T6650759k.java
762 + */
763 +
764 +public class T6650759k {
765 +
766 + static class A<X extends A> {}
767 +
768 + static class B<X extends B, Y extends A> {}
769 +
770 + <U extends A<U>, V extends B<V, U>> Object m(Class<V> c) {
771 + return null;
772 + }
773 +
774 + <U extends A<U>, V extends B<V, U>> void test(Class<V> c) {
775 + m(c);
776 + }
777 +}
778 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759l.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759l.java
779 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759l.java 1970-01-01 01:00:00.000000000 +0100
780 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759l.java 2010-09-09 20:24:56.248744935 +0100
781 @@ -0,0 +1,46 @@
782 +/*
783 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
784 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
785 + *
786 + * This code is free software; you can redistribute it and/or modify it
787 + * under the terms of the GNU General Public License version 2 only, as
788 + * published by the Free Software Foundation.
789 + *
790 + * This code is distributed in the hope that it will be useful, but WITHOUT
791 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
792 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
793 + * version 2 for more details (a copy is included in the LICENSE file that
794 + * accompanied this code).
795 + *
796 + * You should have received a copy of the GNU General Public License version
797 + * 2 along with this work; if not, write to the Free Software Foundation,
798 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
799 + *
800 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
801 + * CA 95054 USA or visit www.sun.com if you need additional information or
802 + * have any questions.
803 + */
804 +
805 +/*
806 + * @test
807 + * @bug 6650759
808 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
809 + * @compile T6650759l.java
810 + */
811 +
812 +public class T6650759l {
813 +
814 + public static interface A<X> {}
815 +
816 + public static class B implements A<Integer> {}
817 +
818 + public static <X extends A<Y>, Y> Y m1(X x) {
819 + return null;
820 + }
821 +
822 + public static void m2(Integer i) {}
823 +
824 + public static void test(B b) {
825 + m2(m1(b));
826 + }
827 +}
828 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759m.java openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759m.java
829 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759m.java 1970-01-01 01:00:00.000000000 +0100
830 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759m.java 2010-09-09 20:24:56.248744935 +0100
831 @@ -0,0 +1,47 @@
832 +/*
833 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
834 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
835 + *
836 + * This code is free software; you can redistribute it and/or modify it
837 + * under the terms of the GNU General Public License version 2 only, as
838 + * published by the Free Software Foundation.
839 + *
840 + * This code is distributed in the hope that it will be useful, but WITHOUT
841 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
842 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
843 + * version 2 for more details (a copy is included in the LICENSE file that
844 + * accompanied this code).
845 + *
846 + * You should have received a copy of the GNU General Public License version
847 + * 2 along with this work; if not, write to the Free Software Foundation,
848 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
849 + *
850 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
851 + * CA 95054 USA or visit www.sun.com if you need additional information or
852 + * have any questions.
853 + */
854 +
855 +/*
856 + * @test
857 + * @bug 6650759
858 + * @summary Inference of formal type parameter (unused in formal parameters) is not performed
859 + * @compile/fail/ref=T6650759m.out T6650759m.java -XDrawDiagnostics
860 + */
861 +
862 +import java.util.*;
863 +
864 +class T6650759m {
865 + <Z> List<? super Z> m(List<? extends List<? super Z>> ls) {
866 + return ls.get(0);
867 + }
868 +
869 + void test() {
870 + ArrayList<ArrayList<Integer>> lli = new ArrayList<ArrayList<Integer>>();
871 + ArrayList<Integer> li = new ArrayList<Integer>();
872 + li.add(2);
873 + lli.add(li);
874 + List<? super String> ls = m(lli); //here
875 + ls.add("crash");
876 + Integer i = li.get(1);
877 + }
878 +}
879 diff -Nru openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759m.out openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759m.out
880 --- openjdk.orig/langtools/test/tools/javac/generics/inference/6650759/T6650759m.out 1970-01-01 01:00:00.000000000 +0100
881 +++ openjdk/langtools/test/tools/javac/generics/inference/6650759/T6650759m.out 2010-09-09 20:24:56.248744935 +0100
882 @@ -0,0 +1,2 @@
883 +T6650759m.java:43:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.util.List<? super java.lang.Integer>, java.util.List<? super java.lang.String>
884 +1 error