Lines 40775-40796
Link Here
|
40775 |
|
40775 |
|
40776 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935 |
40776 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935 |
40777 |
// this case is not solved as expected in 1.5 and 1.6 mode; keeping the 1.7 mode |
40777 |
// this case is not solved as expected in 1.5 and 1.6 mode; keeping the 1.7 mode |
40778 |
// activated |
40778 |
// activated test in all modes so we can track any changes |
40779 |
public void test1203b() { |
40779 |
public void test1203b() { |
40780 |
if (this.complianceLevel < ClassFileConstants.JDK1_7) { |
|
|
40781 |
return; |
40782 |
} |
40783 |
String expectedOutput = this.complianceLevel < ClassFileConstants.JDK1_7 |
40780 |
String expectedOutput = this.complianceLevel < ClassFileConstants.JDK1_7 |
40784 |
? "----------\n" + |
40781 |
? "----------\n" + |
40785 |
"1. WARNING in X.java (at line 4)\n" + |
40782 |
"1. WARNING in X.java (at line 4)\n" + |
40786 |
" return this.<String>foobar(one, two);\n" + |
40783 |
" return this.<String>foobar(one, two);\n" + |
40787 |
" ^^^^^^\n" + |
40784 |
" ^^^^^^\n" + |
40788 |
"Unused type arguments for the non generic method foobar(String, String) of type X; it should not be parameterized with arguments <String>\n" + |
40785 |
"Unused type arguments for the non generic method foobar(String, String) of type X; it should not be parameterized with arguments <String>\n" + |
40789 |
"----------\n" + |
40786 |
"----------\n" + |
40790 |
"2. ERROR in X.java (at line 16)\n" + |
40787 |
"2. ERROR in X.java (at line 8)\n" + |
40791 |
" this.<String,String>foobar(one, two);\n" + |
40788 |
" return this.<String>foobar2(one, two);// silenced\n" + |
40792 |
" ^^^^^^\n" + |
40789 |
" ^^^^^^^\n" + |
40793 |
"Incorrect number of type arguments for generic method <T>foobar(String, String) of type Y; it cannot be parameterized with arguments <String, String>\n" + |
40790 |
"The method foobar2(String, String) of type X is not generic; it cannot be parameterized with arguments <String>\n" + |
|
|
40791 |
"----------\n" + |
40792 |
"3. ERROR in X.java (at line 16)\n" + |
40793 |
" this.<String,String>foobar(one, two);\n" + |
40794 |
" ^^^^^^\n" + |
40795 |
"Incorrect number of type arguments for generic method <T>foobar(String, String) of type Y; it cannot be parameterized with arguments <String, String>\n" + |
40794 |
"----------\n" |
40796 |
"----------\n" |
40795 |
: "----------\n" + |
40797 |
: "----------\n" + |
40796 |
"1. WARNING in X.java (at line 4)\n" + |
40798 |
"1. WARNING in X.java (at line 4)\n" + |
Lines 40829-40834
Link Here
|
40829 |
expectedOutput); |
40831 |
expectedOutput); |
40830 |
} |
40832 |
} |
40831 |
|
40833 |
|
|
|
40834 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935 |
40835 |
public void test1203c() { |
40836 |
String[] sources = |
40837 |
new String[] { |
40838 |
"X.java", |
40839 |
"class X extends Y {\n" + |
40840 |
" public static void main(String[] args) {\n" + |
40841 |
" String s = \"\";\n" + |
40842 |
" new X().<String> a(s);\n" + // fails before 7 |
40843 |
" new X().<String> b(s, s);\n" + // fails before 7 |
40844 |
" new X().<String> c(s, s);\n" + // works in 1.5, 6.0 & 7.0 |
40845 |
" new X().<String> d(s, s);\n" + // works in 1.5, 6.0 & 7.0 |
40846 |
" }\n" + |
40847 |
" @Override void a(String one) {}\n" + |
40848 |
" void b(String one, Object two) {}\n" + |
40849 |
" @Override void c(String one, String two) {}\n" + |
40850 |
" @Override void d(String one, Object two) {}\n" + |
40851 |
"}\n" + |
40852 |
"class Y extends Z {\n" + |
40853 |
" void a(String one) {}\n" + |
40854 |
" <U> void b(String one) {}\n" + |
40855 |
" @Override void c(String one, String two) {}\n" + |
40856 |
"}\n" + |
40857 |
"class Z {\n" + |
40858 |
" <U> void c(String one, String two) {}\n" + |
40859 |
" <U> void d(String one, U u) {}\n" + |
40860 |
"}" |
40861 |
}; |
40862 |
if (this.complianceLevel < ClassFileConstants.JDK1_7) { |
40863 |
runNegativeTest( |
40864 |
sources, |
40865 |
"----------\n" + |
40866 |
"1. ERROR in X.java (at line 4)\n" + |
40867 |
" new X().<String> a(s);\n" + |
40868 |
" ^\n" + |
40869 |
"The method a(String) of type X is not generic; it cannot be parameterized with arguments <String>\n" + |
40870 |
"----------\n" + |
40871 |
"2. ERROR in X.java (at line 5)\n" + |
40872 |
" new X().<String> b(s, s);\n" + |
40873 |
" ^\n" + |
40874 |
"The method b(String, Object) of type X is not generic; it cannot be parameterized with arguments <String>\n" + |
40875 |
"----------\n" + |
40876 |
"3. WARNING in X.java (at line 6)\n" + |
40877 |
" new X().<String> c(s, s);\n" + |
40878 |
" ^^^^^^\n" + |
40879 |
"Unused type arguments for the non generic method c(String, String) of type X; it should not be parameterized with arguments <String>\n" + |
40880 |
"----------\n" + |
40881 |
"4. WARNING in X.java (at line 7)\n" + |
40882 |
" new X().<String> d(s, s);\n" + |
40883 |
" ^^^^^^\n" + |
40884 |
"Unused type arguments for the non generic method d(String, Object) of type X; it should not be parameterized with arguments <String>\n" + |
40885 |
"----------\n"); |
40886 |
} else { |
40887 |
runConformTest( |
40888 |
true, |
40889 |
sources, |
40890 |
"----------\n" + |
40891 |
"1. WARNING in X.java (at line 4)\n" + |
40892 |
" new X().<String> a(s);\n" + |
40893 |
" ^^^^^^\n" + |
40894 |
"Unused type arguments for the non generic method a(String) of type X; it should not be parameterized with arguments <String>\n" + |
40895 |
"----------\n" + |
40896 |
"2. WARNING in X.java (at line 5)\n" + |
40897 |
" new X().<String> b(s, s);\n" + |
40898 |
" ^^^^^^\n" + |
40899 |
"Unused type arguments for the non generic method b(String, Object) of type X; it should not be parameterized with arguments <String>\n" + |
40900 |
"----------\n" + |
40901 |
"3. WARNING in X.java (at line 6)\n" + |
40902 |
" new X().<String> c(s, s);\n" + |
40903 |
" ^^^^^^\n" + |
40904 |
"Unused type arguments for the non generic method c(String, String) of type X; it should not be parameterized with arguments <String>\n" + |
40905 |
"----------\n" + |
40906 |
"4. WARNING in X.java (at line 7)\n" + |
40907 |
" new X().<String> d(s, s);\n" + |
40908 |
" ^^^^^^\n" + |
40909 |
"Unused type arguments for the non generic method d(String, Object) of type X; it should not be parameterized with arguments <String>\n" + |
40910 |
"----------\n", |
40911 |
null, null, |
40912 |
JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); |
40913 |
} |
40914 |
} |
40915 |
|
40916 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935 |
40917 |
public void test1203d() { |
40918 |
String[] sources = |
40919 |
new String[] { |
40920 |
"X.java", |
40921 |
"class X implements I {\n" + |
40922 |
" public static void main(String[] args) {\n" + |
40923 |
" String s = \"\";\n" + |
40924 |
" new X().<String> a(s);\n" + // fails before 7 |
40925 |
" new X().<String> b(s, s);\n" + // fails before 7 |
40926 |
" new X().<String> c(s, s);\n" + // fails before 7 |
40927 |
" new X().<String> d(s, s);\n" + // fails before 7 |
40928 |
" }\n" + |
40929 |
" public void a(String one) {}\n" + |
40930 |
" public void b(String one, Object two) {}\n" + |
40931 |
" public void c(String one, String two) {}\n" + |
40932 |
" public void d(String one, Object two) {}\n" + |
40933 |
"}\n" + |
40934 |
"interface I extends J {\n" + |
40935 |
" void a(String one);\n" + |
40936 |
" void c(String one, String two);\n" + |
40937 |
"}\n" + |
40938 |
"interface J {\n" + |
40939 |
" <U> void c(String one, String two);\n" + |
40940 |
" <U> void d(String one, U u);\n" + |
40941 |
"}" |
40942 |
}; |
40943 |
if (this.complianceLevel < ClassFileConstants.JDK1_7) { |
40944 |
runNegativeTest( |
40945 |
sources, |
40946 |
"----------\n" + |
40947 |
"1. ERROR in X.java (at line 4)\n" + |
40948 |
" new X().<String> a(s);\n" + |
40949 |
" ^\n" + |
40950 |
"The method a(String) of type X is not generic; it cannot be parameterized with arguments <String>\n" + |
40951 |
"----------\n" + |
40952 |
"2. ERROR in X.java (at line 5)\n" + |
40953 |
" new X().<String> b(s, s);\n" + |
40954 |
" ^\n" + |
40955 |
"The method b(String, Object) of type X is not generic; it cannot be parameterized with arguments <String>\n" + |
40956 |
"----------\n" + |
40957 |
"3. ERROR in X.java (at line 6)\n" + |
40958 |
" new X().<String> c(s, s);\n" + |
40959 |
" ^\n" + |
40960 |
"The method c(String, String) of type X is not generic; it cannot be parameterized with arguments <String>\n" + |
40961 |
"----------\n" + |
40962 |
"4. ERROR in X.java (at line 7)\n" + |
40963 |
" new X().<String> d(s, s);\n" + |
40964 |
" ^\n" + |
40965 |
"The method d(String, Object) of type X is not generic; it cannot be parameterized with arguments <String>\n" + |
40966 |
"----------\n"); |
40967 |
} else { |
40968 |
runConformTest( |
40969 |
true, |
40970 |
sources, |
40971 |
"----------\n" + |
40972 |
"1. WARNING in X.java (at line 4)\n" + |
40973 |
" new X().<String> a(s);\n" + |
40974 |
" ^^^^^^\n" + |
40975 |
"Unused type arguments for the non generic method a(String) of type X; it should not be parameterized with arguments <String>\n" + |
40976 |
"----------\n" + |
40977 |
"2. WARNING in X.java (at line 5)\n" + |
40978 |
" new X().<String> b(s, s);\n" + |
40979 |
" ^^^^^^\n" + |
40980 |
"Unused type arguments for the non generic method b(String, Object) of type X; it should not be parameterized with arguments <String>\n" + |
40981 |
"----------\n" + |
40982 |
"3. WARNING in X.java (at line 6)\n" + |
40983 |
" new X().<String> c(s, s);\n" + |
40984 |
" ^^^^^^\n" + |
40985 |
"Unused type arguments for the non generic method c(String, String) of type X; it should not be parameterized with arguments <String>\n" + |
40986 |
"----------\n" + |
40987 |
"4. WARNING in X.java (at line 7)\n" + |
40988 |
" new X().<String> d(s, s);\n" + |
40989 |
" ^^^^^^\n" + |
40990 |
"Unused type arguments for the non generic method d(String, Object) of type X; it should not be parameterized with arguments <String>\n" + |
40991 |
"----------\n", |
40992 |
null, null, |
40993 |
JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); |
40994 |
} |
40995 |
} |
40996 |
|
40832 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207299 |
40997 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207299 |
40833 |
public void test1204() { |
40998 |
public void test1204() { |
40834 |
this.runConformTest( |
40999 |
this.runConformTest( |