Lines 5302-5319
Link Here
|
5302 |
// warning: create() in HashOrder overrides <U>create() in DoubleHash; return type requires unchecked conversion |
5302 |
// warning: create() in HashOrder overrides <U>create() in DoubleHash; return type requires unchecked conversion |
5303 |
); |
5303 |
); |
5304 |
} |
5304 |
} |
5305 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=125956 |
5305 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=125956 |
5306 |
public void test081() { |
5306 |
public void test081a() { |
5307 |
this.runNegativeTest( |
5307 |
this.runNegativeTest( |
5308 |
new String[] { |
5308 |
new String[] { |
5309 |
"X.java", |
5309 |
"X.java", |
5310 |
"public abstract class X<U> implements I {\n" + |
5310 |
"public abstract class X<U> implements I {\n" + |
5311 |
" public A<String> foo() { return null; }\n" + |
5311 |
" public A<String> foo() { return null; }\n" + |
5312 |
" public <S> A<U> bar() { return null; }\n" + |
|
|
5313 |
"}\n" + |
5312 |
"}\n" + |
5314 |
"interface I {\n" + |
5313 |
"interface I {\n" + |
5315 |
" <T> A<T> foo();\n" + |
5314 |
" <T> A<T> foo();\n" + |
5316 |
" <S> A<S> bar();\n" + |
|
|
5317 |
"}\n" + |
5315 |
"}\n" + |
5318 |
"class A<V> {}" |
5316 |
"class A<V> {}" |
5319 |
}, |
5317 |
}, |
Lines 5322-5335
Link Here
|
5322 |
" public A<String> foo() { return null; }\r\n" + |
5320 |
" public A<String> foo() { return null; }\r\n" + |
5323 |
" ^\n" + |
5321 |
" ^\n" + |
5324 |
"Type safety: The return type A<String> for foo() from the type X<U> needs unchecked conversion to conform to A<Object> from the type I\n" + |
5322 |
"Type safety: The return type A<String> for foo() from the type X<U> needs unchecked conversion to conform to A<Object> from the type I\n" + |
|
|
5323 |
"----------\n" |
5324 |
); |
5325 |
} |
5326 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=125956 |
5327 |
public void test081b() { |
5328 |
this.runNegativeTest( |
5329 |
new String[] { |
5330 |
"X.java", |
5331 |
"public abstract class X<U> implements I {\n" + |
5332 |
" public <S> A<U> bar() { return null; }\n" + |
5333 |
"}\n" + |
5334 |
"interface I {\n" + |
5335 |
" <S> A<S> bar();\n" + |
5336 |
"}\n" + |
5337 |
"class A<V> {}" |
5338 |
}, |
5325 |
"----------\n" + |
5339 |
"----------\n" + |
5326 |
"2. ERROR in X.java (at line 3)\r\n" + |
5340 |
"1. ERROR in X.java (at line 2)\r\n" + |
5327 |
" public <S> A<U> bar() { return null; }\r\n" + |
5341 |
" public <S> A<U> bar() { return null; }\r\n" + |
5328 |
" ^^^^\n" + |
5342 |
" ^^^^\n" + |
5329 |
"The return type is incompatible with I.bar()\n" + |
5343 |
"The return type is incompatible with I.bar()\n" + |
5330 |
"----------\n" |
5344 |
"----------\n" |
5331 |
// <S>bar() in X cannot implement <S>bar() in I; attempting to use incompatible return type |
|
|
5332 |
// warning: foo() in X implements <T>foo() in I; return type requires unchecked conversion |
5333 |
); |
5345 |
); |
5334 |
} |
5346 |
} |
5335 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=105339 |
5347 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=105339 |
Lines 7544-7547
Link Here
|
7544 |
"Type safety: The return type Enum<?> for foo() from the type X.B needs unchecked conversion to conform to U from the type X.A<T>\n" + |
7556 |
"Type safety: The return type Enum<?> for foo() from the type X.B needs unchecked conversion to conform to U from the type X.A<T>\n" + |
7545 |
"----------\n"); |
7557 |
"----------\n"); |
7546 |
} |
7558 |
} |
|
|
7559 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7560 |
public void test128() { |
7561 |
this.runNegativeTest( |
7562 |
new String[] { |
7563 |
"X.java", |
7564 |
"interface I<U, V> {\n" + |
7565 |
" U foo(Object o, V v);\n" + |
7566 |
"}\n" + |
7567 |
"public class X<U, V> implements I<U, V> {\n" + |
7568 |
" public Object foo(Object o, Object v) {\n" + |
7569 |
" return null;\n" + |
7570 |
" }\n" + |
7571 |
"}\n" |
7572 |
}, |
7573 |
"----------\n" + |
7574 |
"1. WARNING in X.java (at line 5)\n" + |
7575 |
" public Object foo(Object o, Object v) {\n" + |
7576 |
" ^^^^^^\n" + |
7577 |
"Type safety: The return type Object for foo(Object, Object) from the type X<U,V> needs unchecked conversion to conform to U from the type I<U,V>\n" + |
7578 |
"----------\n"); |
7579 |
} |
7580 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7581 |
// variant - Object is not a subtype of Z |
7582 |
public void test129() { |
7583 |
this.runNegativeTest( |
7584 |
new String[] { |
7585 |
"X.java", |
7586 |
"interface I<U, V> {\n" + |
7587 |
" U foo(Object o, V v);\n" + |
7588 |
"}\n" + |
7589 |
"public class X<U extends Z, V> implements I<U, V> {\n" + |
7590 |
" public Object foo(Object o, Object v) {\n" + |
7591 |
" return null;\n" + |
7592 |
" }\n" + |
7593 |
"}\n" + |
7594 |
"class Z {\n" + |
7595 |
"}\n" |
7596 |
}, |
7597 |
"----------\n" + |
7598 |
"1. ERROR in X.java (at line 5)\n" + |
7599 |
" public Object foo(Object o, Object v) {\n" + |
7600 |
" ^^^^^^\n" + |
7601 |
"The return type is incompatible with I<U,V>.foo(Object, V)\n" + |
7602 |
"----------\n"); |
7603 |
} |
7604 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7605 |
// ** variant - Z<Object> is not a subtype of Z<U>, and |Z<U>| = Z, not Z<Object> |
7606 |
public void test130() { |
7607 |
this.runNegativeTest( |
7608 |
new String[] { |
7609 |
"X.java", |
7610 |
"interface I<U, V> {\n" + |
7611 |
" Z<U> foo(Object o, V v);\n" + |
7612 |
"}\n" + |
7613 |
"public class X<U, V> implements I<U, V> {\n" + |
7614 |
" public Z<Object> foo(Object o, Object v) {\n" + |
7615 |
" return null;\n" + |
7616 |
" }\n" + |
7617 |
"}\n" + |
7618 |
"class Z<T> {\n" + |
7619 |
"}" |
7620 |
}, |
7621 |
"----------\n" + |
7622 |
"1. ERROR in X.java (at line 5)\n" + |
7623 |
" public Z<Object> foo(Object o, Object v) {\n" + |
7624 |
" ^^^^^^^^^\n" + |
7625 |
"The return type is incompatible with I<U,V>.foo(Object, V)\n" + |
7626 |
"----------\n"); |
7627 |
} |
7628 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7629 |
// variant - two interfaces |
7630 |
public void test131() { |
7631 |
this.runNegativeTest( |
7632 |
new String[] { |
7633 |
"X.java", |
7634 |
"interface I<U, V> {\n" + |
7635 |
" U foo(Object o, V v);\n" + |
7636 |
"}\n" + |
7637 |
"interface X<U, V> extends I<U, V> {\n" + |
7638 |
" Object foo(Object o, Object v);\n" + |
7639 |
"}\n" |
7640 |
}, |
7641 |
"----------\n" + |
7642 |
"1. WARNING in X.java (at line 5)\n" + |
7643 |
" Object foo(Object o, Object v);\n" + |
7644 |
" ^^^^^^\n" + |
7645 |
"Type safety: The return type Object for foo(Object, Object) from the type X<U,V> needs unchecked conversion to conform to U from the type I<U,V>\n" + |
7646 |
"----------\n"); |
7647 |
} |
7648 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7649 |
// variant - simpler test case |
7650 |
public void test132() { |
7651 |
this.runNegativeTest( |
7652 |
new String[] { |
7653 |
"X.java", |
7654 |
"interface I<U> {\n" + |
7655 |
" U foo();\n" + |
7656 |
"}\n" + |
7657 |
"public class X<U> implements I<U> {\n" + |
7658 |
" public Object foo() {\n" + |
7659 |
" return null;\n" + |
7660 |
" }\n" + |
7661 |
"}\n" |
7662 |
}, |
7663 |
"----------\n" + |
7664 |
"1. ERROR in X.java (at line 5)\n" + |
7665 |
" public Object foo() {\n" + |
7666 |
" ^^^^^^\n" + |
7667 |
"The return type is incompatible with I<U>.foo()\n" + |
7668 |
"----------\n"); |
7669 |
} |
7670 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7671 |
// variant |
7672 |
public void test133() { |
7673 |
this.runNegativeTest( |
7674 |
new String[] { |
7675 |
"X.java", |
7676 |
"public class X<U extends Z> {\n" + |
7677 |
" U foo() {\n" + |
7678 |
" return null;\n" + |
7679 |
" }\n" + |
7680 |
"}\n" + |
7681 |
"class Y<U extends Z> extends X<U> {\n" + |
7682 |
" public Z foo() {\n" + |
7683 |
" return null;\n" + |
7684 |
" }\n" + |
7685 |
"}\n" + |
7686 |
"class Z {\n" + |
7687 |
"}" |
7688 |
}, |
7689 |
"----------\n" + |
7690 |
"1. ERROR in X.java (at line 7)\n" + |
7691 |
" public Z foo() {\n" + |
7692 |
" ^\n" + |
7693 |
"The return type is incompatible with X<U>.foo()\n" + |
7694 |
"----------\n" + |
7695 |
"2. WARNING in X.java (at line 7)\n" + |
7696 |
" public Z foo() {\n" + |
7697 |
" ^^^^^\n" + |
7698 |
"The method foo() of type Y<U> should be tagged with @Override since it actually overrides a superclass method\n" + |
7699 |
"----------\n"); |
7700 |
} |
7701 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7702 |
// variant - unchecked conversion of ZC to ZC<String> that is a subtype of Z<String> |
7703 |
public void test134() { |
7704 |
this.runNegativeTest( |
7705 |
new String[] { |
7706 |
"X.java", |
7707 |
"public class X {\n" + |
7708 |
" Z<String> foo() {\n" + |
7709 |
" return null;\n" + |
7710 |
" }\n" + |
7711 |
"}\n" + |
7712 |
"class Y extends X {\n" + |
7713 |
" public ZC foo() {\n" + |
7714 |
" return null;\n" + |
7715 |
" }\n" + |
7716 |
"}\n" + |
7717 |
"class Z<T> {\n" + |
7718 |
"}\n" + |
7719 |
"class ZC<T> extends Z<T> {\n" + |
7720 |
"}" |
7721 |
}, |
7722 |
"----------\n" + |
7723 |
"1. WARNING in X.java (at line 7)\n" + |
7724 |
" public ZC foo() {\n" + |
7725 |
" ^^\n" + |
7726 |
"ZC is a raw type. References to generic type ZC<T> should be parameterized\n" + |
7727 |
"----------\n" + |
7728 |
"2. WARNING in X.java (at line 7)\n" + |
7729 |
" public ZC foo() {\n" + |
7730 |
" ^^\n" + |
7731 |
"Type safety: The return type ZC for foo() from the type Y needs unchecked conversion to conform to Z<String> from the type X\n" + |
7732 |
"----------\n" + |
7733 |
"3. WARNING in X.java (at line 7)\n" + |
7734 |
" public ZC foo() {\n" + |
7735 |
" ^^^^^\n" + |
7736 |
"The method foo() of type Y should be tagged with @Override since it actually overrides a superclass method\n" + |
7737 |
"----------\n"); |
7738 |
} |
7739 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789 |
7740 |
// variant - cast is not appropriate |
7741 |
public void test135() { |
7742 |
this.runNegativeTest( |
7743 |
new String[] { |
7744 |
"X.java", |
7745 |
"interface I<U, V> {\n" + |
7746 |
" U foo(Object o, V v);\n" + |
7747 |
"}\n" + |
7748 |
"interface J<U, V> extends I<U, V> {\n" + |
7749 |
" Object foo(Object o, V v);\n" + |
7750 |
"}\n" + |
7751 |
"class X {\n" + |
7752 |
" J<Integer, Integer> m1;\n" + |
7753 |
" I<Integer, Integer> m2 = (I<Integer, Integer>) m1;\n" + |
7754 |
"}" |
7755 |
}, |
7756 |
"----------\n" + |
7757 |
"1. ERROR in X.java (at line 5)\n" + |
7758 |
" Object foo(Object o, V v);\n" + |
7759 |
" ^^^^^^\n" + |
7760 |
"The return type is incompatible with I<U,V>.foo(Object, V)\n" + |
7761 |
"----------\n" + |
7762 |
"2. WARNING in X.java (at line 9)\n" + |
7763 |
" I<Integer, Integer> m2 = (I<Integer, Integer>) m1;\n" + |
7764 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
7765 |
"Unnecessary cast from J<Integer,Integer> to I<Integer,Integer>\n" + |
7766 |
"----------\n"); |
7767 |
} |
7547 |
} |
7768 |
} |