|
Lines 14-21
Link Here
|
| 14 |
*******************************************************************************/ |
14 |
*******************************************************************************/ |
| 15 |
package org.eclipse.jdt.core.tests.compiler.regression; |
15 |
package org.eclipse.jdt.core.tests.compiler.regression; |
| 16 |
|
16 |
|
| 17 |
import java.util.Map; |
|
|
| 18 |
|
| 19 |
import junit.framework.Test; |
17 |
import junit.framework.Test; |
| 20 |
public class GenericsRegressionTest_1_7 extends AbstractRegressionTest { |
18 |
public class GenericsRegressionTest_1_7 extends AbstractRegressionTest { |
| 21 |
|
19 |
|
|
Lines 30-36
Link Here
|
| 30 |
public static Test suite() { |
28 |
public static Test suite() { |
| 31 |
return buildMinimalComplianceTestSuite(testClass(), F_1_7); |
29 |
return buildMinimalComplianceTestSuite(testClass(), F_1_7); |
| 32 |
} |
30 |
} |
| 33 |
public void _test001() { |
31 |
public void test001() { |
| 34 |
this.runConformTest( |
32 |
this.runConformTest( |
| 35 |
new String[] { |
33 |
new String[] { |
| 36 |
"X.java", |
34 |
"X.java", |
|
Lines 46-52
Link Here
|
| 46 |
}, |
44 |
}, |
| 47 |
"SUCCESS"); |
45 |
"SUCCESS"); |
| 48 |
} |
46 |
} |
| 49 |
public void _test001a() { |
47 |
public void test001a() { |
| 50 |
this.runNegativeTest( |
48 |
this.runNegativeTest( |
| 51 |
new String[] { |
49 |
new String[] { |
| 52 |
"X.java", |
50 |
"X.java", |
|
Lines 67-73
Link Here
|
| 67 |
"The method testFunction(String) in the type X<String> is not applicable for the arguments (int)\n" + |
65 |
"The method testFunction(String) in the type X<String> is not applicable for the arguments (int)\n" + |
| 68 |
"----------\n"); |
66 |
"----------\n"); |
| 69 |
} |
67 |
} |
| 70 |
public void _test001b() { |
68 |
public void test001b() { |
| 71 |
this.runConformTest( |
69 |
this.runConformTest( |
| 72 |
new String[] { |
70 |
new String[] { |
| 73 |
"X.java", |
71 |
"X.java", |
|
Lines 82-88
Link Here
|
| 82 |
"SUCCESS"); |
80 |
"SUCCESS"); |
| 83 |
} |
81 |
} |
| 84 |
// fields |
82 |
// fields |
| 85 |
public void _test001b_1() { |
83 |
public void test001b_1() { |
| 86 |
this.runConformTest( |
84 |
this.runConformTest( |
| 87 |
new String[] { |
85 |
new String[] { |
| 88 |
"X.java", |
86 |
"X.java", |
|
Lines 96-102
Link Here
|
| 96 |
}, |
94 |
}, |
| 97 |
"SUCCESS"); |
95 |
"SUCCESS"); |
| 98 |
} |
96 |
} |
| 99 |
public void _test001c() { |
97 |
public void test001c() { |
| 100 |
this.runNegativeTest( |
98 |
this.runNegativeTest( |
| 101 |
new String[] { |
99 |
new String[] { |
| 102 |
"X.java", |
100 |
"X.java", |
|
Lines 116-122
Link Here
|
| 116 |
"----------\n"); |
114 |
"----------\n"); |
| 117 |
} |
115 |
} |
| 118 |
// fields |
116 |
// fields |
| 119 |
public void _test001c_1() { |
117 |
public void test001c_1() { |
| 120 |
this.runNegativeTest( |
118 |
this.runNegativeTest( |
| 121 |
new String[] { |
119 |
new String[] { |
| 122 |
"X.java", |
120 |
"X.java", |
|
Lines 174-180
Link Here
|
| 174 |
"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Integer>)\n" + |
172 |
"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Integer>)\n" + |
| 175 |
"----------\n"); |
173 |
"----------\n"); |
| 176 |
} |
174 |
} |
| 177 |
public void _test001f() { |
175 |
public void test001f() { |
| 178 |
this.runConformTest( |
176 |
this.runConformTest( |
| 179 |
new String[] { |
177 |
new String[] { |
| 180 |
"X.java", |
178 |
"X.java", |
|
Lines 193-199
Link Here
|
| 193 |
"SUCCESS"); |
191 |
"SUCCESS"); |
| 194 |
} |
192 |
} |
| 195 |
// fields |
193 |
// fields |
| 196 |
public void _test001f_1() { |
194 |
public void test001f_1() { |
| 197 |
this.runConformTest( |
195 |
this.runConformTest( |
| 198 |
new String[] { |
196 |
new String[] { |
| 199 |
"X.java", |
197 |
"X.java", |
|
Lines 213-219
Link Here
|
| 213 |
}, |
211 |
}, |
| 214 |
"SUCCESS"); |
212 |
"SUCCESS"); |
| 215 |
} |
213 |
} |
| 216 |
public void _test001g() { |
214 |
public void test001g() { |
| 217 |
this.runConformTest( |
215 |
this.runConformTest( |
| 218 |
new String[] { |
216 |
new String[] { |
| 219 |
"X.java", |
217 |
"X.java", |
|
Lines 232-238
Link Here
|
| 232 |
}, |
230 |
}, |
| 233 |
"SUCCESS\n1"); |
231 |
"SUCCESS\n1"); |
| 234 |
} |
232 |
} |
| 235 |
public void _test001g_1() { |
233 |
public void test001g_1() { |
| 236 |
this.runConformTest( |
234 |
this.runConformTest( |
| 237 |
new String[] { |
235 |
new String[] { |
| 238 |
"X.java", |
236 |
"X.java", |
|
Lines 253-259
Link Here
|
| 253 |
}, |
251 |
}, |
| 254 |
"SUCCESS\n1"); |
252 |
"SUCCESS\n1"); |
| 255 |
} |
253 |
} |
| 256 |
public void _test001h() { |
254 |
public void test001h() { |
| 257 |
this.runNegativeTest( |
255 |
this.runNegativeTest( |
| 258 |
new String[] { |
256 |
new String[] { |
| 259 |
"X.java", |
257 |
"X.java", |
|
Lines 281-287
Link Here
|
| 281 |
"The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + |
279 |
"The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + |
| 282 |
"----------\n"); |
280 |
"----------\n"); |
| 283 |
} |
281 |
} |
| 284 |
public void _test001h_1() { |
282 |
public void test001h_1() { |
| 285 |
this.runNegativeTest( |
283 |
this.runNegativeTest( |
| 286 |
new String[] { |
284 |
new String[] { |
| 287 |
"X.java", |
285 |
"X.java", |
|
Lines 326-332
Link Here
|
| 326 |
"Type safety: The method methodx(Object) belongs to the raw type X.X2. References to generic type X<T>.X2<T> should be parameterized\n" + |
324 |
"Type safety: The method methodx(Object) belongs to the raw type X.X2. References to generic type X<T>.X2<T> should be parameterized\n" + |
| 327 |
"----------\n"); |
325 |
"----------\n"); |
| 328 |
} |
326 |
} |
| 329 |
public void _test001i() { |
327 |
public void test001i() { |
| 330 |
this.runConformTest( |
328 |
this.runConformTest( |
| 331 |
new String[] { |
329 |
new String[] { |
| 332 |
"X.java", |
330 |
"X.java", |
|
Lines 347-353
Link Here
|
| 347 |
}, |
345 |
}, |
| 348 |
"SUCCESS"); |
346 |
"SUCCESS"); |
| 349 |
} |
347 |
} |
| 350 |
public void _test002() { |
348 |
public void test002() { |
| 351 |
this.runNegativeTest( |
349 |
this.runNegativeTest( |
| 352 |
new String[] { |
350 |
new String[] { |
| 353 |
"X.java", |
351 |
"X.java", |
|
Lines 389-395
Link Here
|
| 389 |
"SUCCESS"); |
387 |
"SUCCESS"); |
| 390 |
} |
388 |
} |
| 391 |
|
389 |
|
| 392 |
public void _test004b() { |
390 |
public void test004b() { |
| 393 |
this.runNegativeTest( |
391 |
this.runNegativeTest( |
| 394 |
new String[] { |
392 |
new String[] { |
| 395 |
"X.java", |
393 |
"X.java", |
|
Lines 408-417
Link Here
|
| 408 |
"1. ERROR in X.java (at line 5)\n" + |
406 |
"1. ERROR in X.java (at line 5)\n" + |
| 409 |
" new X<>().new X2<>(){\n" + |
407 |
" new X<>().new X2<>(){\n" + |
| 410 |
" ^^\n" + |
408 |
" ^^\n" + |
| 411 |
"Empty type argument list cannot be used in anonymous class declaration\n" + |
409 |
"Incorrect number of arguments for type X<>.X2; it cannot be parameterized with arguments <>\n" + |
| 412 |
"----------\n"); |
410 |
"----------\n"); |
| 413 |
} |
411 |
} |
| 414 |
public void _test004c() { |
412 |
public void test004c() { |
| 415 |
this.runConformTest( |
413 |
this.runConformTest( |
| 416 |
new String[] { |
414 |
new String[] { |
| 417 |
"X.java", |
415 |
"X.java", |
|
Lines 434-440
Link Here
|
| 434 |
"1"); |
432 |
"1"); |
| 435 |
} |
433 |
} |
| 436 |
|
434 |
|
| 437 |
public void _test006() { |
435 |
public void test006() { |
| 438 |
this.runConformTest( |
436 |
this.runConformTest( |
| 439 |
new String[] { |
437 |
new String[] { |
| 440 |
"X.java", |
438 |
"X.java", |
|
Lines 530-588
Link Here
|
| 530 |
"2"); |
528 |
"2"); |
| 531 |
} |
529 |
} |
| 532 |
|
530 |
|
| 533 |
// To be activated if we introduce a warning to be raised when <> can be used but is not used. |
531 |
public void test0014() { |
| 534 |
public void _test012() { |
|
|
| 535 |
Map options = getCompilerOptions(); |
| 536 |
//options.put(CompilerOptions.OPTION_ReportRedundantDeclarationOfTypeArguments, CompilerOptions.ERROR); |
| 537 |
this.runNegativeTest( |
| 538 |
new String[] { |
| 539 |
"X.java", |
| 540 |
"public class X<T> {\n" + |
| 541 |
" X<String> f1 = new X<String>();\n" + |
| 542 |
" public void foo() {\n" + |
| 543 |
" X<Integer> i1 = new X<Integer>();\n" + |
| 544 |
" }\n" + |
| 545 |
"}", |
| 546 |
}, |
| 547 |
"----------\n" + |
| 548 |
"1. ERROR in X.java (at line 2)\n" + |
| 549 |
" X<String> f1 = new X<String>();\n" + |
| 550 |
" ^^^^^^^^^^^^^^^\n" + |
| 551 |
"Redundant declaration of type arguments <String>\n" + |
| 552 |
"----------\n" + |
| 553 |
"2. ERROR in X.java (at line 4)\n" + |
| 554 |
" X<Integer> i1 = new X<Integer>();\n" + |
| 555 |
" ^^^^^^^^^^^^^^^^\n" + |
| 556 |
"Redundant declaration of type arguments <Integer>\n" + |
| 557 |
"----------\n", |
| 558 |
null, |
| 559 |
true, |
| 560 |
options); |
| 561 |
} |
| 562 |
// To be activated if we introduce a warning to be raised when <> can be used but is not used. |
| 563 |
public void _test013a() { |
| 564 |
Map options = getCompilerOptions(); |
| 565 |
//options.put(CompilerOptions.OPTION_ReportRedundantDeclarationOfTypeArguments, CompilerOptions.ERROR); |
| 566 |
this.runConformTest( |
| 567 |
new String[] { |
| 568 |
"X.java", |
| 569 |
"public class X<T> {\n" + |
| 570 |
" class Y<U>{}\n" + |
| 571 |
" Y<String> f1 = new Y();\n" + |
| 572 |
" public static void main(String[] args) {\n" + |
| 573 |
" X<Integer> i1 = new X<>();\n" + |
| 574 |
" System.out.println(\"SUCCESS\");\n" + |
| 575 |
" }\n" + |
| 576 |
"}", |
| 577 |
}, |
| 578 |
"SUCCESS", |
| 579 |
null, |
| 580 |
true, |
| 581 |
null, |
| 582 |
options, |
| 583 |
null); |
| 584 |
} |
| 585 |
public void _test0014() { |
| 586 |
this.runConformTest( |
532 |
this.runConformTest( |
| 587 |
new String[] { |
533 |
new String[] { |
| 588 |
"X.java", |
534 |
"X.java", |
|
Lines 600-606
Link Here
|
| 600 |
"SUCCESS\n" + |
546 |
"SUCCESS\n" + |
| 601 |
"123"); |
547 |
"123"); |
| 602 |
} |
548 |
} |
| 603 |
public void _test0014a() { |
549 |
public void test0014a() { |
| 604 |
this.runNegativeTest( |
550 |
this.runNegativeTest( |
| 605 |
new String[] { |
551 |
new String[] { |
| 606 |
"X.java", |
552 |
"X.java", |
|
Lines 622-628
Link Here
|
| 622 |
"The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + |
568 |
"The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + |
| 623 |
"----------\n"); |
569 |
"----------\n"); |
| 624 |
} |
570 |
} |
| 625 |
public void _test0015() { |
571 |
public void test0015() { |
| 626 |
this.runConformTest( |
572 |
this.runConformTest( |
| 627 |
new String[] { |
573 |
new String[] { |
| 628 |
"X.java", |
574 |
"X.java", |
|
Lines 643-649
Link Here
|
| 643 |
} |
589 |
} |
| 644 |
// To verify that a parameterized invocation of a generic constructor works even if <> is used |
590 |
// To verify that a parameterized invocation of a generic constructor works even if <> is used |
| 645 |
// to elide class type parameters. |
591 |
// to elide class type parameters. |
| 646 |
public void _test0016() { |
592 |
public void test0016() { |
| 647 |
this.runConformTest( |
593 |
this.runConformTest( |
| 648 |
new String[] { |
594 |
new String[] { |
| 649 |
"X.java", |
595 |
"X.java", |
|
Lines 664-670
Link Here
|
| 664 |
} |
610 |
} |
| 665 |
// To verify that a parameterized invocation of a generic constructor works even if <> is used |
611 |
// To verify that a parameterized invocation of a generic constructor works even if <> is used |
| 666 |
// to elide class type parameters. This test handles fields |
612 |
// to elide class type parameters. This test handles fields |
| 667 |
public void _test0016b() { |
613 |
public void test0016b() { |
| 668 |
this.runConformTest( |
614 |
this.runConformTest( |
| 669 |
new String[] { |
615 |
new String[] { |
| 670 |
"X.java", |
616 |
"X.java", |
|
Lines 689-695
Link Here
|
| 689 |
// To verify that a parameterized invocation of a non-generic constructor works even if <> is used |
635 |
// To verify that a parameterized invocation of a non-generic constructor works even if <> is used |
| 690 |
// to elide class type parameters. |
636 |
// to elide class type parameters. |
| 691 |
// This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230) |
637 |
// This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230) |
| 692 |
public void _test0017() { |
638 |
public void test0017() { |
| 693 |
this.runConformTest( |
639 |
this.runConformTest( |
| 694 |
new String[] { |
640 |
new String[] { |
| 695 |
"X.java", |
641 |
"X.java", |
|
Lines 711-717
Link Here
|
| 711 |
"const.1\nconst.1\nconst.2"); |
657 |
"const.1\nconst.1\nconst.2"); |
| 712 |
} |
658 |
} |
| 713 |
// To verify that the correct constructor is found by parameter substitution in the diamond case |
659 |
// To verify that the correct constructor is found by parameter substitution in the diamond case |
| 714 |
public void _test0018() { |
660 |
public void test0018() { |
| 715 |
this.runConformTest( |
661 |
this.runConformTest( |
| 716 |
new String[] { |
662 |
new String[] { |
| 717 |
"X.java", |
663 |
"X.java", |
|
Lines 732-738
Link Here
|
| 732 |
} |
678 |
} |
| 733 |
// To verify that the correct constructor is found by parameter substitution |
679 |
// To verify that the correct constructor is found by parameter substitution |
| 734 |
// in the diamond case -- fields |
680 |
// in the diamond case -- fields |
| 735 |
public void _test0018b() { |
681 |
public void test0018b() { |
| 736 |
this.runConformTest( |
682 |
this.runConformTest( |
| 737 |
new String[] { |
683 |
new String[] { |
| 738 |
"X.java", |
684 |
"X.java", |