Lines 1875-1878
Link Here
|
1875 |
}, |
1875 |
}, |
1876 |
""); |
1876 |
""); |
1877 |
} |
1877 |
} |
|
|
1878 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163590 |
1879 |
// ** |
1880 |
public void test047() { |
1881 |
this.runNegativeTest( |
1882 |
new String[] { |
1883 |
"X.java", |
1884 |
"public class X<T extends I & J> {\n" + |
1885 |
" void foo(T t) {\n" + |
1886 |
" }\n" + |
1887 |
"}\n" + |
1888 |
"interface I {\n" + |
1889 |
" public int method();\n" + |
1890 |
"}\n" + |
1891 |
"interface J {\n" + |
1892 |
" public boolean method();\n" + |
1893 |
"}\n" |
1894 |
}, |
1895 |
"----------\n" + |
1896 |
"1. ERROR in X.java (at line 1)\n" + |
1897 |
" public class X<T extends I & J> {\n" + |
1898 |
" ^\n" + |
1899 |
"The return type is incompatible with J.method(), I.method()\n" + |
1900 |
"----------\n"); |
1901 |
} |
1902 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163590 |
1903 |
// Variant: javac complains as well if we attempt to use method, but noone |
1904 |
// complains upon bar or CONSTANT. |
1905 |
public void test048() { |
1906 |
this.runNegativeTest( |
1907 |
new String[] { |
1908 |
"X.java", |
1909 |
"public class X<T extends I & J> {\n" + |
1910 |
" void foo(T t) {\n" + |
1911 |
" t.method();\n" + |
1912 |
" t.bar();\n" + |
1913 |
" if (t.CONSTANT > 0);\n" + |
1914 |
" }\n" + |
1915 |
"}\n" + |
1916 |
"interface I {\n" + |
1917 |
" public int method();\n" + |
1918 |
" void bar();\n" + |
1919 |
"}\n" + |
1920 |
"interface J {\n" + |
1921 |
" public boolean method();\n" + |
1922 |
" static final int CONSTANT = 0;\n" + |
1923 |
"}\n" |
1924 |
}, |
1925 |
"----------\n" + |
1926 |
"1. ERROR in X.java (at line 1)\n" + |
1927 |
" public class X<T extends I & J> {\n" + |
1928 |
" ^\n" + |
1929 |
"The return type is incompatible with J.method(), I.method()\n" + |
1930 |
"----------\n" + |
1931 |
"2. ERROR in X.java (at line 3)\n" + |
1932 |
" t.method();\n" + |
1933 |
" ^^^^^^\n" + |
1934 |
"The method method() is ambiguous for the type T\n" + |
1935 |
"----------\n" + |
1936 |
"3. WARNING in X.java (at line 5)\n" + |
1937 |
" if (t.CONSTANT > 0);\n" + |
1938 |
" ^^^^^^^^\n" + |
1939 |
"The static field J.CONSTANT should be accessed in a static way\n" + |
1940 |
"----------\n"); |
1941 |
} |
1942 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163590 |
1943 |
// can't implement both interfaces though |
1944 |
public void test049() { |
1945 |
this.runNegativeTest( |
1946 |
new String[] { |
1947 |
"X.java", |
1948 |
"interface I {\n" + |
1949 |
" public int method();\n" + |
1950 |
"}\n" + |
1951 |
"interface J {\n" + |
1952 |
" public boolean method();\n" + |
1953 |
"}\n" + |
1954 |
"class X implements I, J {\n" + |
1955 |
" public int method() {\n" + |
1956 |
" return 0;\n" + |
1957 |
" }\n" + |
1958 |
"}" |
1959 |
}, |
1960 |
"----------\n" + |
1961 |
"1. ERROR in X.java (at line 8)\n" + |
1962 |
" public int method() {\n" + |
1963 |
" ^^^\n" + |
1964 |
"The return type is incompatible with J.method()\n" + |
1965 |
"----------\n"); |
1966 |
} |
1967 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163590 |
1968 |
// variant: secure the legal case |
1969 |
public void test050() { |
1970 |
this.runConformTest( |
1971 |
new String[] { |
1972 |
"X.java", |
1973 |
"public class X<T extends I & J> {\n" + |
1974 |
" void foo(T t) {\n" + |
1975 |
" }\n" + |
1976 |
"}\n" + |
1977 |
"interface I {\n" + |
1978 |
" public int method();\n" + |
1979 |
"}\n" + |
1980 |
"interface J {\n" + |
1981 |
" public int method();\n" + |
1982 |
"}\n" |
1983 |
}, |
1984 |
""); |
1985 |
} |
1878 |
} |
1986 |
} |