Lines 784-787
Link Here
|
784 |
assertTrue("Y#foo() should not override X#foo()", !bindings[0].overrides(bindings[1])); |
784 |
assertTrue("Y#foo() should not override X#foo()", !bindings[0].overrides(bindings[1])); |
785 |
} |
785 |
} |
786 |
|
786 |
|
|
|
787 |
/* |
788 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
789 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
790 |
*/ |
791 |
public void test035() throws JavaModelException { |
792 |
IMethodBinding[] bindings = createMethodBindings( |
793 |
new String[] { |
794 |
"/P/p1/A.java", |
795 |
"package p1;\n" + |
796 |
"public class A<T> {\n" + |
797 |
" public void o1_xoo2(A<?> s) {\n" + |
798 |
" }\n" + |
799 |
"}\n" + |
800 |
"class B<S> extends A<S> {\n" + |
801 |
" @Override\n" + |
802 |
" public void o1_xoo2(A<Object> s) {\n" + |
803 |
" }\n" + |
804 |
"}", |
805 |
}, |
806 |
new String[] { |
807 |
"Lp1/A;.o1_xoo2(Lp1/A<*>;)V", |
808 |
"Lp1/A~B;.o1_xoo2(Lp1/A<Ljava/lang/Object;>;)V" |
809 |
}); |
810 |
assertFalse("B#o1_xoo2() should not be a subsignature of A#o1_xoo2()", bindings[1].isSubsignature(bindings[0])); |
811 |
} |
812 |
|
813 |
/* |
814 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
815 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
816 |
*/ |
817 |
public void test036() throws JavaModelException { |
818 |
IMethodBinding[] bindings = createMethodBindings( |
819 |
new String[] { |
820 |
"/P/p1/A.java", |
821 |
"package p1;\n" + |
822 |
"public class A<T> {\n" + |
823 |
" public void o1_xoo3(A<? extends T> s) {\n" + |
824 |
" }\n" + |
825 |
"}\n" + |
826 |
"class B<S> extends A<S> {\n" + |
827 |
" @Override\n" + |
828 |
" public void o1_xoo3(A<? super S> s) {\n" + |
829 |
" }\n" + |
830 |
"}", |
831 |
}, |
832 |
new String[] { |
833 |
"Lp1/A;.o1_xoo3(Lp1/A<+TT;>;)V", |
834 |
"Lp1/A~B;.o1_xoo3(Lp1/A<-TS;>;)V" |
835 |
}); |
836 |
assertFalse("B#o1_xoo3() should not be a subsignature of A#o1_xoo3()", bindings[1].isSubsignature(bindings[0])); |
837 |
} |
838 |
|
839 |
/* |
840 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
841 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
842 |
*/ |
843 |
public void test037() throws JavaModelException { |
844 |
IMethodBinding[] bindings = createMethodBindings( |
845 |
new String[] { |
846 |
"/P/p1/A.java", |
847 |
"package p1;\n" + |
848 |
"public class A<S, T> {\n" + |
849 |
" public void o2_xoo1(List<? extends T> t) {\n" + |
850 |
" }\n" + |
851 |
"}\n" + |
852 |
"class B<V, W> extends A<W, V> {\n" + |
853 |
" @Override\n" + |
854 |
" public void o2_xoo1(List<? extends W> t) {\n" + |
855 |
" }\n" + |
856 |
"}\n" + |
857 |
"class List<T> {\n" + |
858 |
"}", |
859 |
}, |
860 |
new String[] { |
861 |
"Lp1/A;.o2_xoo1(Lp1/List<+TT;>;)V", |
862 |
"Lp1/A~B;.o2_xoo1(Lp1/List<+TW;>;)V" |
863 |
}); |
864 |
assertFalse("B#o1_xoo1() should not be a subsignature of A#o1_xoo1()", bindings[1].isSubsignature(bindings[0])); |
865 |
} |
866 |
|
867 |
/* |
868 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
869 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
870 |
*/ |
871 |
public void test038() throws JavaModelException { |
872 |
IMethodBinding[] bindings = createMethodBindings( |
873 |
new String[] { |
874 |
"/P/p1/A.java", |
875 |
"package p1;\n" + |
876 |
"public class A {\n" + |
877 |
" public void o3_xoo1(List t) {\n" + |
878 |
" }\n" + |
879 |
"}\n" + |
880 |
"class B extends A {\n" + |
881 |
" @Override\n" + |
882 |
" public void o3_xoo1(List<Object> t) {\n" + |
883 |
" }\n" + |
884 |
"}\n" + |
885 |
"class List<T> {\n" + |
886 |
"}", |
887 |
}, |
888 |
new String[] { |
889 |
"Lp1/A;.o3_xoo1(Lp1/List;)V", |
890 |
"Lp1/A~B;.o3_xoo1(Lp1/List<Ljava/lang/Object;>;)V" |
891 |
}); |
892 |
assertFalse("B#o3_xoo1() should not be a subsignature of A#o3_xoo1()", bindings[1].isSubsignature(bindings[0])); |
893 |
} |
894 |
|
895 |
/* |
896 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
897 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
898 |
*/ |
899 |
public void test039() throws JavaModelException { |
900 |
IMethodBinding[] bindings = createMethodBindings( |
901 |
new String[] { |
902 |
"/P/p1/A.java", |
903 |
"package p1;\n" + |
904 |
"public class A<T> {\n" + |
905 |
" public void o4_xoo1(T t) {\n" + |
906 |
" }\n" + |
907 |
"}\n" + |
908 |
"class B extends A<List<String>> {\n" + |
909 |
" @Override\n" + |
910 |
" public void o4_xoo1(List<?> t) {\n" + |
911 |
" }\n" + |
912 |
"}\n" + |
913 |
"class List<T> {\n" + |
914 |
"}", |
915 |
}, |
916 |
new String[] { |
917 |
"Lp1/A;.o4_xoo1(TT;)V", |
918 |
"Lp1/A~B;.o4_xoo1(Lp1/List<*>;)V" |
919 |
}); |
920 |
assertFalse("B#o4_xoo1() should not be a subsignature of A#o4_xoo1()", bindings[1].isSubsignature(bindings[0])); |
921 |
} |
922 |
|
923 |
/* |
924 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
925 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
926 |
*/ |
927 |
public void test040() throws JavaModelException { |
928 |
IMethodBinding[] bindings = createMethodBindings( |
929 |
new String[] { |
930 |
"/P/p1/A.java", |
931 |
"package p1;\n" + |
932 |
"public class A<S> {\n" + |
933 |
" public <X, Y> void tp1_xoo3(X x, Y y) {\n" + |
934 |
" }\n" + |
935 |
"}\n" + |
936 |
"class B extends A<String> {\n" + |
937 |
" @Override\n" + |
938 |
" public <W, V> void tp1_xoo3(V x, W y) {\n" + |
939 |
" }\n" + |
940 |
"}", |
941 |
}, |
942 |
new String[] { |
943 |
"Lp1/A;.tp1_xoo3<X:Ljava/lang/Object;Y:Ljava/lang/Object;>(TX;TY;)V", |
944 |
"Lp1/A~B;.tp1_xoo3<W:Ljava/lang/Object;V:Ljava/lang/Object;>(TV;TW;)V" |
945 |
}); |
946 |
assertFalse("B#tp1_xoo3() should not be a subsignature of A#tp1_xoo3()", bindings[1].isSubsignature(bindings[0])); |
947 |
} |
948 |
|
949 |
/* |
950 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
951 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
952 |
*/ |
953 |
public void test041() throws JavaModelException { |
954 |
IMethodBinding[] bindings = createMethodBindings( |
955 |
new String[] { |
956 |
"/P/p1/A.java", |
957 |
"package p1;\n" + |
958 |
"public class A<S> {\n" + |
959 |
" public <X, Y> void tp1_foo2(S s, X x, Y y) {\n" + |
960 |
" }\n" + |
961 |
"}\n" + |
962 |
"class B extends A<String> {\n" + |
963 |
" @Override\n" + |
964 |
" public void tp1_foo2(String s, Object x, Object y) {\n" + |
965 |
" }\n" + |
966 |
"}", |
967 |
}, |
968 |
new String[] { |
969 |
"Lp1/A;.tp1_foo2<X:Ljava/lang/Object;Y:Ljava/lang/Object;>(TS;TX;TY;)V", |
970 |
"Lp1/A~B;.tp1_foo2(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V" |
971 |
}); |
972 |
assertTrue("B#tp1_foo2() should be a subsignature of A#tp1_foo2()", bindings[1].isSubsignature(bindings[0])); |
973 |
} |
974 |
|
975 |
/* |
976 |
* Ensures that a method with different paramter types is not a subsignature of its super method. |
977 |
* (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) |
978 |
*/ |
979 |
public void test042() throws JavaModelException { |
980 |
IMethodBinding[] bindings = createMethodBindings( |
981 |
new String[] { |
982 |
"/P/p1/A.java", |
983 |
"package p1;\n" + |
984 |
"public abstract class A<T> {\n" + |
985 |
" void g2 (T t) {\n" + |
986 |
" }\n" + |
987 |
"}\n" + |
988 |
"class B extends A<List<Number>> {\n" + |
989 |
" void g2 (List<Number> t) {\n" + |
990 |
" }\n" + |
991 |
"}\n" + |
992 |
"class List<T> {\n" + |
993 |
"}\n" + |
994 |
"class Number {\n" + |
995 |
"}", |
996 |
}, |
997 |
new String[] { |
998 |
"Lp1/A~B;.g2(Lp1/List<Lp1/Number;>;)V" |
999 |
}); |
1000 |
ITypeBinding superType = bindings[0].getDeclaringClass().getSuperclass(); // parameterized type |
1001 |
IMethodBinding ag2 = superType.getDeclaredMethods()[1]; |
1002 |
assertTrue("B#g2() should be a subsignature of A#g2()", bindings[0].isSubsignature(ag2)); |
1003 |
} |
1004 |
|
787 |
} |
1005 |
} |