View | Details | Raw Unified | Return to bug 174588 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java (+139 lines)
Lines 2729-2734 Link Here
2729
		},
2729
		},
2730
		"X\nX");
2730
		"X\nX");
2731
}
2731
}
2732
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=174588
2733
public void test081() {
2734
	this.runConformTest(
2735
		new String[] {
2736
			"X.java",	//===================
2737
			"public class X extends Y {\n" + 
2738
			"  public void set(int value) {\n" + 
2739
			"      System.out.println(\"set(\" + value + \")\");\n" + 
2740
			"  }\n" + 
2741
			"  public static void main(String[] args) {\n" + 
2742
			"    X x = new X();\n" + 
2743
			"    x.set(1L);\n" + 
2744
			"  }\n" + 
2745
			"}\n" + 
2746
			"abstract class Y implements I {\n" + 
2747
			"  public void set(long value) {\n" + 
2748
			"    set((int)value);\n" + 
2749
			"  }\n" + 
2750
			"  public void set(double value) {\n" + 
2751
			"    set((int)value);\n" + 
2752
			"  }\n" + 
2753
			"}\n" + 
2754
			"interface I {\n" + 
2755
			"  void set(int value);\n" + 
2756
			"  void set(long value);\n" + 
2757
			"}\n", 		// =================
2758
		},
2759
		"set(1)");
2760
}
2761
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=174588
2762
// variant
2763
public void test082() {
2764
	this.runConformTest(
2765
		new String[] {
2766
			"X.java",	//===================
2767
			"public class X extends Y {\n" + 
2768
			"  public void set(int value) {\n" + 
2769
			"      System.out.println(\"set(\" + value + \")\");\n" + 
2770
			"  }\n" + 
2771
			"  public static void main(String[] args) {\n" + 
2772
			"    X x = new X();\n" + 
2773
			"    x.set(1L);\n" + 
2774
			"  }\n" + 
2775
			"}\n" + 
2776
			"abstract class Y implements I {\n" + 
2777
			"  public abstract void set(int value);\n" + 
2778
			"  public void set(long value) {\n" + 
2779
			"    set((int)value);\n" + 
2780
			"  }\n" + 
2781
			"  public void set(double value) {\n" + 
2782
			"    set((int)value);\n" + 
2783
			"  }\n" + 
2784
			"}\n" + 
2785
			"interface I {\n" + 
2786
			"  void set(int value);\n" + 
2787
			"  void set(long value);\n" + 
2788
			"}\n", 		// =================
2789
		},
2790
		"set(1)");
2791
}
2792
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=174588
2793
// variant
2794
public void test083() {
2795
	String src[] = 
2796
		new String[] {
2797
			"X.java",
2798
			"public class X extends Z {\n" + 
2799
			"  public void set(int value) {\n" + 
2800
			"      System.out.println(\"set(\" + value + \")\");\n" + 
2801
			"  }\n" + 
2802
			"  public static void main(String[] args) {\n" + 
2803
			"    X x = new X();\n" + 
2804
			"    x.set(1L);\n" + 
2805
			"  }\n" + 
2806
			"}\n" + 
2807
			"abstract class Z extends Y {\n" + 
2808
			"  public void set(long value) {\n" + 
2809
			"    set((int)value);\n" + 
2810
			"  }\n" + 
2811
			"  public void set(double value) {\n" + 
2812
			"    set((int)value);\n" + 
2813
			"  }\n" + 
2814
			"}\n" + 
2815
			"abstract class Y implements I {\n" + 
2816
			"}\n" + 
2817
			"interface I {\n" + 
2818
			"  void set(int value);\n" + 
2819
			"  void set(long value);\n" + 
2820
			"}\n",
2821
		};
2822
	if (complianceLevel.compareTo(COMPLIANCE_1_3) <= 0) {
2823
		this.runNegativeTest(
2824
			src,
2825
			"----------\n" + 
2826
			"1. ERROR in X.java (at line 12)\r\n" + 
2827
			"	set((int)value);\r\n" + 
2828
			"	^^^\n" + 
2829
			"The method set(long) is ambiguous for the type Z\n" + 
2830
			"----------\n" + 
2831
			"2. ERROR in X.java (at line 15)\r\n" + 
2832
			"	set((int)value);\r\n" + 
2833
			"	^^^\n" + 
2834
			"The method set(long) is ambiguous for the type Z\n" + 
2835
			"----------\n");
2836
	} else {
2837
		this.runConformTest(
2838
			src,
2839
			"set(1)");
2840
	}
2841
}
2842
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=174588
2843
// variant
2844
public void test084() {
2845
	this.runConformTest(
2846
		new String[] {
2847
			"X.java",	//===================
2848
			"public class X extends Y {\n" + 
2849
			"  public void set(int value, int i) {\n" + 
2850
			"      System.out.println(\"set(\" + value + \")\");\n" + 
2851
			"  }\n" + 
2852
			"  public static void main(String[] args) {\n" + 
2853
			"    X x = new X();\n" + 
2854
			"    x.set(1L, 1);\n" + 
2855
			"  }\n" + 
2856
			"}\n" + 
2857
			"abstract class Y implements I {\n" + 
2858
			"  public void set(long value, int i) {\n" + 
2859
			"    set((int)value, i);\n" + 
2860
			"  }\n" + 
2861
			"  public void set(int i, double value) {\n" + 
2862
			"    set(i, (int)value);\n" + 
2863
			"  }\n" + 
2864
			"}\n" + 
2865
			"interface I {\n" + 
2866
			"  void set(int value, int i);\n" + 
2867
			"}\n", 		// =================
2868
		},
2869
		"set(1)");
2870
}
2732
public static Class testClass() {	return LookupTest.class;
2871
public static Class testClass() {	return LookupTest.class;
2733
}
2872
}
2734
}
2873
}

Return to bug 174588