Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 216686
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+501 lines)
Lines 42124-42127 Link Here
42124
			},
42124
			},
42125
			"");
42125
			"");
42126
}
42126
}
42127
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686
42128
public void test1269() {
42129
	this.runConformTest(
42130
			new String[] {
42131
					"X.java",
42132
					"public class X {\n" + 
42133
					"	// some functor and functor instances definitions\n" + 
42134
					"	static interface OO<T, E> { \n" + 
42135
					"		public T eval(E x);\n" + 
42136
					"	}\n" + 
42137
					"	static interface TO<T> extends OO<String, T> {\n" + 
42138
					"		public String eval(T x);\n" + 
42139
					"	}\n" + 
42140
					"	static interface TT extends TO<String> {\n" + 
42141
					"		public String eval(String x);\n" + 
42142
					"	}\n" + 
42143
					"	static final TO<Object> FUNC1 = null;\n" + 
42144
					"	static final TT FUNC2 = null;\n" + 
42145
					"\n" + 
42146
					"	// some functor combinators\n" + 
42147
					"	static <E> TO<E> combine(final TT x, final TO<? super E> y) { // # 1\n" + 
42148
					"		System.out.println(\"#1#\");\n" + 
42149
					"		return new TO<E>() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + 
42150
					"	}\n" + 
42151
					"	// body of the test\n" + 
42152
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42153
					"	}\n" + 
42154
					"	public static void main(String[] args) {\n" + 
42155
					"		put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42156
					"	}\n" + 
42157
					"}\n", // =================
42158
			},
42159
			"#1#");
42160
}
42161
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42162
public void test1270() {
42163
	this.runConformTest(
42164
			new String[] {
42165
					"X.java",
42166
					"public class X {\n" + 
42167
					"	// some functor and functor instances definitions\n" + 
42168
					"	static interface OO<T, E> { \n" + 
42169
					"		public T eval(E x);\n" + 
42170
					"	}\n" + 
42171
					"	static interface TO<T> extends OO<String, T> {\n" + 
42172
					"		public String eval(T x);\n" + 
42173
					"	}\n" + 
42174
					"	static interface TT extends TO<String> {\n" + 
42175
					"		public String eval(String x);\n" + 
42176
					"	}\n" + 
42177
					"	static final TO<Object> FUNC1 = null;\n" + 
42178
					"	static final TT FUNC2 = null;\n" + 
42179
					"\n" + 
42180
					"	// some functor combinators\n" + 
42181
					"	static <E, T> TO<T> combine(final TO<? super E> x, final OO<E, T> y) { // # 2\n" + 
42182
					"		System.out.println(\"#2#\");\n" + 
42183
					"		return new TO<T>() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + 
42184
					"	}\n" + 
42185
					"	// body of the test\n" + 
42186
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42187
					"	}\n" + 
42188
					"	public static void main(String[] args) {\n" + 
42189
					"		put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42190
					"	}\n" + 
42191
					"}\n", // =================
42192
			},
42193
			"#2#");
42194
}
42195
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42196
public void test1271() {
42197
	this.runNegativeTest(
42198
			new String[] {
42199
					"X.java",
42200
					"public class X {\n" + 
42201
					"	// some functor and functor instances definitions\n" + 
42202
					"	static interface OO<T, E> { \n" + 
42203
					"		public T eval(E x);\n" + 
42204
					"	}\n" + 
42205
					"	static interface TO<T> extends OO<String, T> {\n" + 
42206
					"		public String eval(T x);\n" + 
42207
					"	}\n" + 
42208
					"	static interface TT extends TO<String> {\n" + 
42209
					"		public String eval(String x);\n" + 
42210
					"	}\n" + 
42211
					"	static final TO<Object> FUNC1 = null;\n" + 
42212
					"	static final TT FUNC2 = null;\n" + 
42213
					"\n" + 
42214
					"	// some functor combinators\n" + 
42215
					"	static <E, T, V> OO<E, V> combine(final OO<E, ? super T> x, final OO<T, V> y) { // # 3\n" + 
42216
					"		System.out.println(\"#3#\");\n" + 
42217
					"		return new OO<E, V>() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + 
42218
					"	}\n" + 
42219
					"	// body of the test\n" + 
42220
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42221
					"	}\n" + 
42222
					"	public static void main(String[] args) {\n" + 
42223
					"		put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42224
					"	}\n" + 
42225
					"}\n", // =================
42226
			},
42227
			"----------\n" + 
42228
			"1. ERROR in X.java (at line 24)\n" + 
42229
			"	put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42230
			"	^^^\n" + 
42231
			"The method put(Class<E>, X.TO<? super E>) in the type X is not applicable for the arguments (Class<Integer>, X.OO<String,Object>)\n" + 
42232
			"----------\n");
42233
}
42234
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42235
public void test1272() {
42236
	this.runConformTest(
42237
			new String[] {
42238
					"X.java",
42239
					"public class X {\n" + 
42240
					"	// some functor and functor instances definitions\n" + 
42241
					"	static interface OO<T, E> { \n" + 
42242
					"		public T eval(E x);\n" + 
42243
					"	}\n" + 
42244
					"	static interface TO<T> extends OO<String, T> {\n" + 
42245
					"		public String eval(T x);\n" + 
42246
					"	}\n" + 
42247
					"	static interface TT extends TO<String> {\n" + 
42248
					"		public String eval(String x);\n" + 
42249
					"	}\n" + 
42250
					"	static final TO<Object> FUNC1 = null;\n" + 
42251
					"	static final TT FUNC2 = null;\n" + 
42252
					"\n" + 
42253
					"	// some functor combinators\n" + 
42254
					"	static <E, T, V> OO<E, V> combine(final OO<E, ? super T> x, final OO<T, V> y) { // # 3\n" + 
42255
					"		System.out.print(\"#3#\");\n" + 
42256
					"		return new OO<E, V>() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + 
42257
					"	}\n" + 
42258
					"	// body of the test\n" + 
42259
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42260
					"	}\n" + 
42261
					"	public static void main(String[] args) {\n" + 
42262
					"      try {\n" +
42263
					"		   put(Integer.class, (TO<Object>)combine(FUNC2, FUNC1));\n" + 
42264
					"      } catch(ClassCastException e) {\n" +
42265
					"		   System.out.println(\"#CLASSCAST#\");\n" + 
42266
					"		}\n" +
42267
					"	}\n" + 
42268
					"}\n", // =================
42269
			},
42270
			"#3##CLASSCAST#");
42271
}
42272
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42273
public void test1273() {
42274
	this.runConformTest(
42275
			new String[] {
42276
					"X.java",
42277
					"public class X {\n" + 
42278
					"	// some functor and functor instances definitions\n" + 
42279
					"	static interface OO<T, E> { \n" + 
42280
					"		public T eval(E x);\n" + 
42281
					"	}\n" + 
42282
					"	static interface TO<T> extends OO<String, T> {\n" + 
42283
					"		public String eval(T x);\n" + 
42284
					"	}\n" + 
42285
					"	static interface TT extends TO<String> {\n" + 
42286
					"		public String eval(String x);\n" + 
42287
					"	}\n" + 
42288
					"	static final TO<Object> FUNC1 = null;\n" + 
42289
					"	static final TT FUNC2 = null;\n" + 
42290
					"\n" + 
42291
					"	// some functor combinators\n" + 
42292
					"	static <E> TO<E> combine(final TT x, final TO<? super E> y) { // # 1\n" + 
42293
					"		System.out.println(\"#1#\");\n" + 
42294
					"		return new TO<E>() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + 
42295
					"	}\n" + 
42296
					"	static <E, T> TO<T> combine(final TO<? super E> x, final OO<E, T> y) { // # 2\n" + 
42297
					"		System.out.println(\"#2#\");\n" + 
42298
					"		return new TO<T>() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + 
42299
					"	}\n" + 
42300
					"	// body of the test\n" + 
42301
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42302
					"	}\n" + 
42303
					"	public static void main(String[] args) {\n" + 
42304
					"		put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42305
					"	}\n" + 
42306
					"}\n", // =================
42307
			},
42308
			"#1#");
42309
}
42310
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42311
public void test1274() {
42312
	this.runConformTest(
42313
			new String[] {
42314
					"X.java",
42315
					"public class X {\n" + 
42316
					"	// some functor and functor instances definitions\n" + 
42317
					"	static interface OO<T, E> { \n" + 
42318
					"		public T eval(E x);\n" + 
42319
					"	}\n" + 
42320
					"	static interface TO<T> extends OO<String, T> {\n" + 
42321
					"		public String eval(T x);\n" + 
42322
					"	}\n" + 
42323
					"	static interface TT extends TO<String> {\n" + 
42324
					"		public String eval(String x);\n" + 
42325
					"	}\n" + 
42326
					"	static final TO<Object> FUNC1 = null;\n" + 
42327
					"	static final TT FUNC2 = null;\n" + 
42328
					"\n" + 
42329
					"	// some functor combinators\n" + 
42330
					"	static <E> TO<E> combine(final TT x, final TO<? super E> y) { // # 1\n" + 
42331
					"		System.out.println(\"#1#\");\n" + 
42332
					"		return new TO<E>() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + 
42333
					"	}\n" + 
42334
					"	static <E, T> TO<T> combine(final TO<? super E> x, final OO<E, T> y) { // # 2\n" + 
42335
					"		System.out.println(\"#2#\");\n" + 
42336
					"		return new TO<T>() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + 
42337
					"	}\n" + 
42338
					"	// body of the test\n" + 
42339
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42340
					"	}\n" + 
42341
					"	public static void main(String[] args) {\n" + 
42342
					"		put(Integer.class, X.<Object>combine(FUNC2, FUNC1));\n" + 
42343
					"	}\n" + 
42344
					"}\n", // =================
42345
			},
42346
			"#1#");
42347
}
42348
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42349
public void test1275() {
42350
	this.runConformTest(
42351
			new String[] {
42352
					"X.java",
42353
					"public class X {\n" + 
42354
					"	// some functor and functor instances definitions\n" + 
42355
					"	static interface OO<T, E> { \n" + 
42356
					"		public T eval(E x);\n" + 
42357
					"	}\n" + 
42358
					"	static interface TO<T> extends OO<String, T> {\n" + 
42359
					"		public String eval(T x);\n" + 
42360
					"	}\n" + 
42361
					"	static interface TT extends TO<String> {\n" + 
42362
					"		public String eval(String x);\n" + 
42363
					"	}\n" + 
42364
					"	static final TO<Object> FUNC1 = null;\n" + 
42365
					"	static final TT FUNC2 = null;\n" + 
42366
					"\n" + 
42367
					"	// some functor combinators\n" + 
42368
					"	static <E> TO<E> combine(final TT x, final TO<? super E> y) { // # 1\n" + 
42369
					"		System.out.println(\"#1#\");\n" + 
42370
					"		return new TO<E>() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + 
42371
					"	}\n" + 
42372
					"	static <E, T, V> OO<E, V> combine(final OO<E, ? super T> x, final OO<T, V> y) { // # 3\n" + 
42373
					"		System.out.println(\"#3#\");\n" + 
42374
					"		return new OO<E, V>() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + 
42375
					"	}\n" + 
42376
					"	// body of the test\n" + 
42377
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42378
					"	}\n" + 
42379
					"	public static void main(String[] args) {\n" + 
42380
					"		put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42381
					"	}\n" + 
42382
					"}\n", // =================
42383
			},
42384
			"#1#");
42385
}
42386
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42387
public void test1276() {
42388
	this.runConformTest(
42389
			new String[] {
42390
					"X.java",
42391
					"public class X {\n" + 
42392
					"	// some functor and functor instances definitions\n" + 
42393
					"	static interface OO<T, E> { \n" + 
42394
					"		public T eval(E x);\n" + 
42395
					"	}\n" + 
42396
					"	static interface TO<T> extends OO<String, T> {\n" + 
42397
					"		public String eval(T x);\n" + 
42398
					"	}\n" + 
42399
					"	static interface TT extends TO<String> {\n" + 
42400
					"		public String eval(String x);\n" + 
42401
					"	}\n" + 
42402
					"	static final TO<Object> FUNC1 = null;\n" + 
42403
					"	static final TT FUNC2 = null;\n" + 
42404
					"\n" + 
42405
					"	// some functor combinators\n" + 
42406
					"	static <E> TO<E> combine(final TT x, final TO<? super E> y) { // # 1\n" + 
42407
					"		System.out.println(\"#1#\");\n" + 
42408
					"		return new TO<E>() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + 
42409
					"	}\n" + 
42410
					"	static <E, T, V> OO<E, V> combine(final OO<E, ? super T> x, final OO<T, V> y) { // # 3\n" + 
42411
					"		System.out.println(\"#3#\");\n" + 
42412
					"		return new OO<E, V>() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + 
42413
					"	}\n" + 
42414
					"	// body of the test\n" + 
42415
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42416
					"	}\n" + 
42417
					"	public static void main(String[] args) {\n" + 
42418
					"		put(Integer.class, X.<Object>combine(FUNC2, FUNC1));\n" + 
42419
					"	}\n" + 
42420
					"}\n", // =================
42421
			},
42422
			"#1#");
42423
}
42424
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42425
public void test1277() {
42426
	this.runConformTest(
42427
			new String[] {
42428
					"X.java",
42429
					"public class X {\n" + 
42430
					"	// some functor and functor instances definitions\n" + 
42431
					"	static interface OO<T, E> { \n" + 
42432
					"		public T eval(E x);\n" + 
42433
					"	}\n" + 
42434
					"	static interface TO<T> extends OO<String, T> {\n" + 
42435
					"		public String eval(T x);\n" + 
42436
					"	}\n" + 
42437
					"	static interface TT extends TO<String> {\n" + 
42438
					"		public String eval(String x);\n" + 
42439
					"	}\n" + 
42440
					"	static final TO<Object> FUNC1 = null;\n" + 
42441
					"	static final TT FUNC2 = null;\n" + 
42442
					"\n" + 
42443
					"	// some functor combinators\n" + 
42444
					"	static <E, T> TO<T> combine(final TO<? super E> x, final OO<E, T> y) { // # 2\n" + 
42445
					"		System.out.println(\"#2#\");\n" + 
42446
					"		return new TO<T>() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + 
42447
					"	}\n" + 
42448
					"	static <E, T, V> OO<E, V> combine(final OO<E, ? super T> x, final OO<T, V> y) { // # 3\n" + 
42449
					"		System.out.println(\"#3#\");\n" + 
42450
					"		return new OO<E, V>() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + 
42451
					"	}\n" + 
42452
					"	// body of the test\n" + 
42453
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42454
					"	}\n" + 
42455
					"	public static void main(String[] args) {\n" + 
42456
					"		put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42457
					"	}\n" + 
42458
					"}\n", // =================
42459
			},
42460
			"#2#");
42461
}
42462
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42463
public void test1278() {
42464
	this.runConformTest(
42465
			new String[] {
42466
					"X.java",
42467
					"public class X {\n" + 
42468
					"	// some functor and functor instances definitions\n" + 
42469
					"	static interface OO<T, E> { \n" + 
42470
					"		public T eval(E x);\n" + 
42471
					"	}\n" + 
42472
					"	static interface TO<T> extends OO<String, T> {\n" + 
42473
					"		public String eval(T x);\n" + 
42474
					"	}\n" + 
42475
					"	static interface TT extends TO<String> {\n" + 
42476
					"		public String eval(String x);\n" + 
42477
					"	}\n" + 
42478
					"	static final TO<Object> FUNC1 = null;\n" + 
42479
					"	static final TT FUNC2 = null;\n" + 
42480
					"\n" + 
42481
					"	// some functor combinators\n" + 
42482
					"	static <E> TO<E> combine(final TT x, final TO<? super E> y) { // # 1\n" + 
42483
					"		System.out.println(\"#1#\");\n" + 
42484
					"		return new TO<E>() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + 
42485
					"	}\n" + 
42486
					"	static <E, T> TO<T> combine(final TO<? super E> x, final OO<E, T> y) { // # 2\n" + 
42487
					"		System.out.println(\"#2#\");\n" + 
42488
					"		return new TO<T>() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + 
42489
					"	}\n" + 
42490
					"	static <E, T, V> OO<E, V> combine(final OO<E, ? super T> x, final OO<T, V> y) { // # 3\n" + 
42491
					"		System.out.println(\"#3#\");\n" + 
42492
					"		return new OO<E, V>() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + 
42493
					"	}\n" + 
42494
					"	// body of the test\n" + 
42495
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42496
					"	}\n" + 
42497
					"	public static void main(String[] args) {\n" + 
42498
					"		put(Integer.class, combine(FUNC2, FUNC1));\n" + 
42499
					"	}\n" + 
42500
					"}\n", // =================
42501
			},
42502
			"#1#");
42503
}
42504
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42505
public void test1279() {
42506
	this.runConformTest(
42507
			new String[] {
42508
					"X.java",
42509
					"public class X {\n" + 
42510
					"	// some functor and functor instances definitions\n" + 
42511
					"	static interface OO<T, E> { \n" + 
42512
					"		public T eval(E x);\n" + 
42513
					"	}\n" + 
42514
					"	static interface TO<T> extends OO<String, T> {\n" + 
42515
					"		public String eval(T x);\n" + 
42516
					"	}\n" + 
42517
					"	static interface TT extends TO<String> {\n" + 
42518
					"		public String eval(String x);\n" + 
42519
					"	}\n" + 
42520
					"	static final TO<Object> FUNC1 = null;\n" + 
42521
					"	static final TT FUNC2 = null;\n" + 
42522
					"\n" + 
42523
					"	// some functor combinators\n" + 
42524
					"	static <E> TO<E> combine(final TT x, final TO<? super E> y) { // # 1\n" + 
42525
					"		System.out.println(\"#1#\");\n" + 
42526
					"		return new TO<E>() { public String eval(E o) { return x.eval(y.eval(o)); } }; \n" + 
42527
					"	}\n" + 
42528
					"	static <E, T> TO<T> combine(final TO<? super E> x, final OO<E, T> y) { // # 2\n" + 
42529
					"		System.out.println(\"#2#\");\n" + 
42530
					"		return new TO<T>() { public String eval(T o) { return x.eval(y.eval(o)); } }; \n" + 
42531
					"	}\n" + 
42532
					"	static <E, T, V> OO<E, V> combine(final OO<E, ? super T> x, final OO<T, V> y) { // # 3\n" + 
42533
					"		System.out.println(\"#3#\");\n" + 
42534
					"		return new OO<E, V>() { public E eval(V o) { return x.eval(y.eval(o)); } };\n" + 
42535
					"	}\n" + 
42536
					"	// body of the test\n" + 
42537
					"	static <E> void put(Class<E> type, TO<? super E> func) {\n" + 
42538
					"	}\n" + 
42539
					"	public static void main(String[] args) {\n" + 
42540
					"		put(Integer.class, X.<Object>combine(FUNC2, FUNC1));\n" + 
42541
					"	}\n" + 
42542
					"}\n", // =================
42543
			},
42544
			"#1#");
42545
}
42546
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42547
public void test1280() {
42548
	this.runConformTest(
42549
			new String[] {
42550
					"X.java",
42551
					"interface OO<T,E> {}\n" + 
42552
					"interface TO<T> extends OO<String,T> {}\n" + 
42553
					"interface TT extends TO<String> {}\n" + 
42554
					"\n" + 
42555
					"public class X {\n" + 
42556
					"	<E, T> TO<T> combine(final TO<? super E> x, final OO<E, T> y) { return null; }\n" + 
42557
					"  void foo(TT tt, TO<? super Object> too) {\n" + 
42558
					"     combine(tt, too);\n" + 
42559
					"  }\n" + 
42560
					"}", // =================
42561
			},
42562
			"");
42563
}
42564
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42565
public void test1281() {
42566
	this.runConformTest(
42567
			new String[] {
42568
					"X.java",
42569
					"interface OO<T,E> {}\n" + 
42570
					"interface TO<T> extends OO<String,T> {}\n" + 
42571
					"interface TT extends TO<String> {}\n" + 
42572
					"\n" + 
42573
					"public class X {\n" + 
42574
					"	<E, T> TO<T> combine(final TO<? super E> x, final OO<E, T>[] y) { return null; }\n" + 
42575
					"  void foo(TT tt, TO<? super Object>[] too) {\n" + 
42576
					"     combine(tt, too);\n" + 
42577
					"  }\n" + 
42578
					"}", // =================
42579
			},
42580
			"");
42581
}
42582
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42583
public void test1282() {
42584
	this.runNegativeTest(
42585
			new String[] {
42586
					"X.java",
42587
					"public class X {\n" + 
42588
					"	static interface OO<T,E> {}\n" + 
42589
					"	static interface TO<T> extends OO<String,T> {}\n" + 
42590
					"	static interface TT extends TO<String> {}\n" + 
42591
					"	\n" + 
42592
					"	<E, T> TO<T> combine(TT x, TO<? super E> y) { return null; }\n" + 
42593
					"	void foo(TO<? super String> too, OO<String,Object> oo) {\n" + 
42594
					"		combine(too, oo);\n" + 
42595
					"	}\n" + 
42596
					"}", // =================
42597
			},
42598
			"----------\n" + 
42599
			"1. ERROR in X.java (at line 8)\r\n" + 
42600
			"	combine(too, oo);\r\n" + 
42601
			"	^^^^^^^\n" + 
42602
			"The method combine(X.TT, X.TO<? super E>) in the type X is not applicable for the arguments (X.TO<capture#1-of ? super String>, X.OO<String,Object>)\n" + 
42603
			"----------\n");
42604
}
42605
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216686 - variation
42606
public void test1283() {
42607
	this.runNegativeTest(
42608
			new String[] {
42609
					"X.java",
42610
					"public class X {\n" + 
42611
					"	static interface OO<T,E> {}\n" + 
42612
					"	static interface TO<T> extends OO<String,T> {}\n" + 
42613
					"	static interface TT extends TO<String> {}\n" + 
42614
					"	\n" + 
42615
					"	<E, T> TO<T> combine(TT[] x, TO<? super E>[] y) { return null; }\n" + 
42616
					"	void foo(TO<? super String>[] too, OO<String,Object>[] oo) {\n" + 
42617
					"		combine(too, oo);\n" + 
42618
					"	}\n" + 
42619
					"}", // =================
42620
			},
42621
			"----------\n" + 
42622
			"1. ERROR in X.java (at line 8)\r\n" + 
42623
			"	combine(too, oo);\r\n" + 
42624
			"	^^^^^^^\n" + 
42625
			"The method combine(X.TT[], X.TO<? super E>[]) in the type X is not applicable for the arguments (X.TO<? super String>[], X.OO<String,Object>[])\n" + 
42626
			"----------\n");
42627
}
42127
}
42628
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java (-1 / +1 lines)
Lines 470-476 Link Here
470
			TypeBinding[] newArguments = new TypeBinding[length];
470
			TypeBinding[] newArguments = new TypeBinding[length];
471
			for (int i = 0; i < length; i++) {
471
			for (int i = 0; i < length; i++) {
472
				TypeVariableBinding originalVariable = originalVariables[i];
472
				TypeVariableBinding originalVariable = originalVariables[i];
473
				if (originalVariable.boundsCount() == 1) {
473
				if (originalVariable.boundsCount() <= 1) {
474
					newArguments[i] = this.environment.convertToRawType(originalVariable.upperBound(), false /*do not force conversion of enclosing types*/);
474
					newArguments[i] = this.environment.convertToRawType(originalVariable.upperBound(), false /*do not force conversion of enclosing types*/);
475
				} else {
475
				} else {
476
					newArguments[i] = this.environment.convertToRawType(
476
					newArguments[i] = this.environment.convertToRawType(
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java (-118 / +129 lines)
Lines 804-941 Link Here
804
	if (this == otherType)
804
	if (this == otherType)
805
		return true;
805
		return true;
806
	switch (otherType.kind()) {
806
	switch (otherType.kind()) {
807
	// allow wildcard containment
807
		// allow wildcard containment
808
	case Binding.WILDCARD_TYPE:
808
		case Binding.WILDCARD_TYPE:
809
	case Binding.INTERSECTION_TYPE:
809
		case Binding.INTERSECTION_TYPE:
810
		
810
			
811
		TypeBinding lowerBound = this;
811
			TypeBinding lowerBound = this;
812
		TypeBinding upperBound = this;
812
			TypeBinding upperBound = this;
813
		switch (this.kind()) {
813
			switch (this.kind()) {
814
			case Binding.WILDCARD_TYPE:
814
				case Binding.WILDCARD_TYPE:
815
			case Binding.INTERSECTION_TYPE:
815
				case Binding.INTERSECTION_TYPE:
816
				WildcardBinding wildcard = (WildcardBinding) this;
816
					WildcardBinding wildcard = (WildcardBinding) this;
817
				switch (wildcard.boundKind) {
817
					switch (wildcard.boundKind) {
818
				case Wildcard.EXTENDS:
818
						case Wildcard.EXTENDS:
819
					if (wildcard.otherBounds != null) // intersection type
819
							if (wildcard.otherBounds != null) // intersection type
820
						break;
820
								break;
821
					upperBound = wildcard.bound;
821
							upperBound = wildcard.bound;
822
					lowerBound = null;
822
							lowerBound = null;
823
							break;
824
						case Wildcard.SUPER:
825
							upperBound = wildcard;
826
							lowerBound = wildcard.bound;
827
							break;
828
						case Wildcard.UNBOUND:
829
							upperBound = wildcard;
830
							lowerBound = null;
831
					}
823
					break;
832
					break;
833
				case Binding.TYPE_PARAMETER:
834
					if (this.isCapture()) {
835
						CaptureBinding capture = (CaptureBinding) this;
836
						if (capture.lowerBound != null)
837
							lowerBound = capture.lowerBound;
838
					}
839
			}
840
			WildcardBinding otherWildcard = (WildcardBinding) otherType;
841
			if (otherWildcard.otherBounds != null)
842
				return false; // not a true wildcard (intersection type)
843
			TypeBinding otherBound = otherWildcard.bound;
844
			switch (otherWildcard.boundKind) {
845
				case Wildcard.EXTENDS:
846
					if (otherBound == this)
847
						return true; // ? extends T  <=  ? extends ? extends T
848
					if (upperBound == null)
849
						return false;
850
					TypeBinding match = upperBound.findSuperTypeOriginatingFrom(otherBound);
851
					if (match != null && (match = match.leafComponentType()).isRawType()) {
852
						return match == otherBound.leafComponentType(); // forbide: Collection <=  ? extends Collection<?>
853
																												// forbide: Collection[] <=  ? extends Collection<?>[]
854
					}
855
					return upperBound.isCompatibleWith(otherBound);
856
		
824
				case Wildcard.SUPER:
857
				case Wildcard.SUPER:
825
					upperBound = wildcard;
858
					if (otherBound == this)
826
					lowerBound = wildcard.bound;
859
						return true; // ? super T  <=  ? super ? super T
827
					break;
860
					if (lowerBound == null)
861
						return false;
862
					match = otherBound.findSuperTypeOriginatingFrom(lowerBound);
863
					if (match != null && (match = match.leafComponentType()).isRawType()) {
864
						return match == lowerBound.leafComponentType(); // forbide: Collection <=  ? super Collection<?>
865
																												// forbide: Collection[] <=  ? super Collection<?>[]
866
					}
867
					return otherBound.isCompatibleWith(lowerBound);
868
		
828
				case Wildcard.UNBOUND:
869
				case Wildcard.UNBOUND:
829
					upperBound = wildcard;
870
				default:
830
					lowerBound = null;
871
					return true;
831
				}
832
				break;
833
			case Binding.TYPE_PARAMETER:
834
				if (this.isCapture()) {
835
					CaptureBinding capture = (CaptureBinding) this;
836
					if (capture.lowerBound != null)
837
						lowerBound = capture.lowerBound;
838
				}
839
		}
840
		WildcardBinding otherWildcard = (WildcardBinding) otherType;
841
		if (otherWildcard.otherBounds != null)
842
			return false; // not a true wildcard (intersection type)
843
		TypeBinding otherBound = otherWildcard.bound;
844
		switch (otherWildcard.boundKind) {
845
		case Wildcard.EXTENDS:
846
			if (otherBound == this)
847
				return true; // ? extends T  <=  ? extends ? extends T
848
			if (upperBound == null)
849
				return false;
850
			TypeBinding match = upperBound.findSuperTypeOriginatingFrom(otherBound);
851
			if (match != null && (match = match.leafComponentType()).isRawType()) {
852
				return match == otherBound.leafComponentType(); // forbide: Collection <=  ? extends Collection<?>
853
																										// forbide: Collection[] <=  ? extends Collection<?>[]
854
			}
872
			}
855
			return upperBound.isCompatibleWith(otherBound);
873
			// allow List<?> to match List<? extends Object> (and reciprocally)
856
874
		case Binding.PARAMETERIZED_TYPE:
857
		case Wildcard.SUPER:
875
			if (!this.isParameterizedType())
858
			if (otherBound == this)
859
				return true; // ? super T  <=  ? super ? super T
860
			if (lowerBound == null)
861
				return false;
876
				return false;
862
			match = otherBound.findSuperTypeOriginatingFrom(lowerBound);
877
			ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) this;
863
			if (match != null && (match = match.leafComponentType()).isRawType()) {
878
			ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType;
864
				return match == lowerBound.leafComponentType(); // forbide: Collection <=  ? super Collection<?>
879
			if (paramType.actualType() != otherParamType.actualType())
865
																										// forbide: Collection[] <=  ? super Collection<?>[]
880
				return false;
866
			}
881
			if (!paramType.isStatic()) { // static member types do not compare their enclosing
867
			return otherBound.isCompatibleWith(lowerBound);
882
				ReferenceBinding enclosing = enclosingType();
868
883
				if (enclosing != null) {
869
		case Wildcard.UNBOUND:
884
					ReferenceBinding otherEnclosing = otherParamType	.enclosingType();
870
		default:
885
					if (otherEnclosing == null)
871
			return true;
872
		}
873
		// allow List<?> to match List<? extends Object> (and reciprocally)
874
	case Binding.PARAMETERIZED_TYPE:
875
		if (!this.isParameterizedType())
876
			return false;
877
		ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) this;
878
		ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType;
879
		if (paramType.actualType() != otherParamType.actualType())
880
			return false;
881
		if (!paramType.isStatic()) { // static member types do not compare their enclosing
882
			ReferenceBinding enclosing = enclosingType();
883
			if (enclosing != null) {
884
				ReferenceBinding otherEnclosing = otherParamType	.enclosingType();
885
				if (otherEnclosing == null)
886
					return false;
887
				if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) {
888
					if (enclosing != otherEnclosing)
889
						return false;
890
				} else {
891
					if (!enclosing.isEquivalentTo(otherParamType.enclosingType()))
892
						return false;
886
						return false;
887
					if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) {
888
						if (enclosing != otherEnclosing)
889
							return false;
890
					} else {
891
						if (!enclosing.isEquivalentTo(otherParamType.enclosingType()))
892
							return false;
893
					}
893
				}
894
				}
894
			}
895
			}
895
		}
896
			int length = paramType.arguments == null ? 0 : paramType.arguments.length;
896
		int length = paramType.arguments == null ? 0 : paramType.arguments.length;
897
			TypeBinding[] otherArguments = otherParamType.arguments;
897
		TypeBinding[] otherArguments = otherParamType.arguments;
898
			int otherLength = otherArguments == null ? 0 : otherArguments.length;
898
		int otherLength = otherArguments == null ? 0 : otherArguments.length;
899
			if (otherLength != length)
899
		if (otherLength != length)
900
			return false;
901
		nextArgument: for (int i = 0; i < length; i++) {
902
			TypeBinding argument = paramType.arguments[i];
903
			TypeBinding otherArgument = otherArguments[i];
904
			if (argument == otherArgument)
905
				continue nextArgument;
906
			int kind = argument.kind();
907
			if (otherArgument.kind() != kind)
908
				return false;
900
				return false;
909
			switch (kind) {
901
			nextArgument: for (int i = 0; i < length; i++) {
910
			case Binding.PARAMETERIZED_TYPE:
902
				TypeBinding argument = paramType.arguments[i];
911
				if (argument.isTypeArgumentContainedBy(otherArgument)) // recurse
903
				TypeBinding otherArgument = otherArguments[i];
904
				if (argument == otherArgument)
912
					continue nextArgument;
905
					continue nextArgument;
913
				break;
906
				int kind = argument.kind();
907
				if (otherArgument.kind() != kind)
908
					return false;
909
				switch (kind) {
910
					case Binding.PARAMETERIZED_TYPE:
911
						if (argument.isTypeArgumentContainedBy(otherArgument)) // recurse
912
							continue nextArgument;
913
						break;
914
					case Binding.WILDCARD_TYPE:
915
					case Binding.INTERSECTION_TYPE:
916
						WildcardBinding wildcard = (WildcardBinding) argument;
917
						otherWildcard = (WildcardBinding) otherArgument;
918
						switch (wildcard.boundKind) {
919
						case Wildcard.EXTENDS:
920
							// match "? extends <upperBound>" with "?"
921
							if (otherWildcard.boundKind == Wildcard.UNBOUND
922
									&& wildcard.bound == wildcard.typeVariable().upperBound())
923
								continue nextArgument;
924
							break;
925
						case Wildcard.SUPER:
926
							break;
927
						case Wildcard.UNBOUND:
928
							// match "?" with "? extends <upperBound>"
929
							if (otherWildcard.boundKind == Wildcard.EXTENDS
930
									&& otherWildcard.bound == otherWildcard.typeVariable().upperBound())
931
								continue nextArgument;
932
							break;
933
						}
934
						break;
935
				}
936
				return false;
937
			}
938
			return true;
939
	}
940
	// (? super Object) <= Object
941
	if (otherType.id == TypeIds.T_JavaLangObject) {
942
		switch (this.kind()) {
914
			case Binding.WILDCARD_TYPE:
943
			case Binding.WILDCARD_TYPE:
915
			case Binding.INTERSECTION_TYPE:
944
				WildcardBinding wildcard = (WildcardBinding) this;
916
				WildcardBinding wildcard = (WildcardBinding) argument;
945
				if (wildcard.boundKind == Wildcard.SUPER && wildcard.bound.id == TypeIds.T_JavaLangObject) {
917
				otherWildcard = (WildcardBinding) otherArgument;
946
					return true;
918
				switch (wildcard.boundKind) {
919
				case Wildcard.EXTENDS:
920
					// match "? extends <upperBound>" with "?"
921
					if (otherWildcard.boundKind == Wildcard.UNBOUND
922
							&& wildcard.bound == wildcard.typeVariable().upperBound())
923
						continue nextArgument;
924
					break;
925
				case Wildcard.SUPER:
926
					break;
927
				case Wildcard.UNBOUND:
928
					// match "?" with "? extends <upperBound>"
929
					if (otherWildcard.boundKind == Wildcard.EXTENDS
930
							&& otherWildcard.bound == otherWildcard.typeVariable().upperBound())
931
						continue nextArgument;
932
					break;
933
				}
947
				}
934
				break;
948
				break;
935
			}
936
			return false;
937
		}
949
		}
938
		return true;
939
	}
950
	}
940
	return false;
951
	return false;
941
}
952
}

Return to bug 216686