Lines 4847-4850
Link Here
|
4847 |
}, |
4847 |
}, |
4848 |
"IJdone"); |
4848 |
"IJdone"); |
4849 |
} |
4849 |
} |
|
|
4850 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=264843 |
4851 |
public void test168() { |
4852 |
this.runNegativeTest( |
4853 |
new String[] { |
4854 |
"X.java", |
4855 |
"public class X {\n" + |
4856 |
" <T extends Integer> T a() { return 35; }\n" + |
4857 |
" <T extends Integer> T[] b() { return new int[]{35}; }\n" + |
4858 |
" <T extends Integer> T c() { return new Integer(35); }\n" + |
4859 |
" <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + |
4860 |
"}\n", |
4861 |
}, |
4862 |
"----------\n" + |
4863 |
"1. WARNING in X.java (at line 2)\n" + |
4864 |
" <T extends Integer> T a() { return 35; }\n" + |
4865 |
" ^^^^^^^\n" + |
4866 |
"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + |
4867 |
"----------\n" + |
4868 |
"2. ERROR in X.java (at line 2)\n" + |
4869 |
" <T extends Integer> T a() { return 35; }\n" + |
4870 |
" ^^\n" + |
4871 |
"Type mismatch: cannot convert from int to T\n" + |
4872 |
"----------\n" + |
4873 |
"3. WARNING in X.java (at line 3)\n" + |
4874 |
" <T extends Integer> T[] b() { return new int[]{35}; }\n" + |
4875 |
" ^^^^^^^\n" + |
4876 |
"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + |
4877 |
"----------\n" + |
4878 |
"4. ERROR in X.java (at line 3)\n" + |
4879 |
" <T extends Integer> T[] b() { return new int[]{35}; }\n" + |
4880 |
" ^^^^^^^^^^^^^\n" + |
4881 |
"Type mismatch: cannot convert from int[] to T[]\n" + |
4882 |
"----------\n" + |
4883 |
"5. WARNING in X.java (at line 4)\n" + |
4884 |
" <T extends Integer> T c() { return new Integer(35); }\n" + |
4885 |
" ^^^^^^^\n" + |
4886 |
"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + |
4887 |
"----------\n" + |
4888 |
"6. ERROR in X.java (at line 4)\n" + |
4889 |
" <T extends Integer> T c() { return new Integer(35); }\n" + |
4890 |
" ^^^^^^^^^^^^^^^\n" + |
4891 |
"Type mismatch: cannot convert from Integer to T\n" + |
4892 |
"----------\n" + |
4893 |
"7. WARNING in X.java (at line 5)\n" + |
4894 |
" <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + |
4895 |
" ^^^^^^^\n" + |
4896 |
"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + |
4897 |
"----------\n" + |
4898 |
"8. ERROR in X.java (at line 5)\n" + |
4899 |
" <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + |
4900 |
" ^^^^^^^^^^^^^^^^^\n" + |
4901 |
"Type mismatch: cannot convert from Integer[] to T[]\n" + |
4902 |
"----------\n" + |
4903 |
"9. WARNING in X.java (at line 5)\n" + |
4904 |
" <T extends Integer> T[] d() { return new Integer[]{35}; }\n" + |
4905 |
" ^^\n" + |
4906 |
"The expression of type int is boxed into Integer\n" + |
4907 |
"----------\n"); |
4908 |
} |
4909 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=264843 |
4910 |
public void test169() { |
4911 |
this.runNegativeTest( |
4912 |
new String[] { |
4913 |
"X.java", |
4914 |
"public class X<T extends Integer> {\n" + |
4915 |
" T x = 12;\n" + |
4916 |
" Byte y = 12;\n" + |
4917 |
" void x(T t) {\n" + |
4918 |
" t = 5;\n" + |
4919 |
" switch (t) {\n" + |
4920 |
" case 1:\n" + |
4921 |
" break;\n" + |
4922 |
" }\n" + |
4923 |
" }\n" + |
4924 |
" void y(Byte t) {\n" + |
4925 |
" t = 5;\n" + |
4926 |
" switch (t) {\n" + |
4927 |
" case 1:\n" + |
4928 |
" break;\n" + |
4929 |
" }\n" + |
4930 |
" }\n" + |
4931 |
"}\n", |
4932 |
}, |
4933 |
"----------\n" + |
4934 |
"1. WARNING in X.java (at line 1)\n" + |
4935 |
" public class X<T extends Integer> {\n" + |
4936 |
" ^^^^^^^\n" + |
4937 |
"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + |
4938 |
"----------\n" + |
4939 |
"2. ERROR in X.java (at line 2)\n" + |
4940 |
" T x = 12;\n" + |
4941 |
" ^^\n" + |
4942 |
"Type mismatch: cannot convert from int to T\n" + |
4943 |
"----------\n" + |
4944 |
"3. WARNING in X.java (at line 3)\n" + |
4945 |
" Byte y = 12;\n" + |
4946 |
" ^^\n" + |
4947 |
"The expression of type int is boxed into Byte\n" + |
4948 |
"----------\n" + |
4949 |
"4. ERROR in X.java (at line 5)\n" + |
4950 |
" t = 5;\n" + |
4951 |
" ^\n" + |
4952 |
"Type mismatch: cannot convert from int to T\n" + |
4953 |
"----------\n" + |
4954 |
"5. WARNING in X.java (at line 6)\n" + |
4955 |
" switch (t) {\n" + |
4956 |
" ^\n" + |
4957 |
"The expression of type T is unboxed into int\n" + |
4958 |
"----------\n" + |
4959 |
"6. ERROR in X.java (at line 7)\n" + |
4960 |
" case 1:\n" + |
4961 |
" ^\n" + |
4962 |
"Type mismatch: cannot convert from int to T\n" + |
4963 |
"----------\n" + |
4964 |
"7. WARNING in X.java (at line 12)\n" + |
4965 |
" t = 5;\n" + |
4966 |
" ^\n" + |
4967 |
"The expression of type int is boxed into Byte\n" + |
4968 |
"----------\n" + |
4969 |
"8. WARNING in X.java (at line 13)\n" + |
4970 |
" switch (t) {\n" + |
4971 |
" ^\n" + |
4972 |
"The expression of type Byte is unboxed into int\n" + |
4973 |
"----------\n"); |
4974 |
} |
4850 |
} |
4975 |
} |