diff options
author | Srikanth | 2011-11-17 12:26:22 +0000 |
---|---|---|
committer | Srikanth | 2011-11-17 12:26:22 +0000 |
commit | 85f48e0f08275e1f81e9995073d5c4f69bfd0707 (patch) | |
tree | 9f73aa20e6419bbe69987f8c7d00609b62a82559 /org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java | |
parent | 0edd2a8da94febc0bef7418a02cfac9f1a30d36a (diff) | |
download | eclipse.jdt.core-85f48e0f08275e1f81e9995073d5c4f69bfd0707.tar.gz eclipse.jdt.core-85f48e0f08275e1f81e9995073d5c4f69bfd0707.tar.xz eclipse.jdt.core-85f48e0f08275e1f81e9995073d5c4f69bfd0707.zip |
Fixed bug 346038: [1.5][compiler] ecj vs. javac differ for methods using
vararg parameters of different primitive types
Fixed bug 346039: [1.5][compiler] ecj vs. javac differ for varargs
overloading
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java')
-rw-r--r-- | org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java | 157 |
1 files changed, 153 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java index f4c4f70abd..200f2ee94e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java @@ -777,7 +777,7 @@ public class VarargsTest extends AbstractComparableTest { } public void test015() { // check behaviour of Scope.mostSpecificMethodBinding() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -790,7 +790,12 @@ public class VarargsTest extends AbstractComparableTest { " public static void count(int[] array, int[] ... values) { System.out.print(2); }\n" + "}\n", }, - "1" + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Y.count(new int[0]);\n" + + " ^^^^^\n" + + "The method count(int[], int[]) is ambiguous for the type Y\n" + + "----------\n" ); } @@ -1232,7 +1237,7 @@ public class VarargsTest extends AbstractComparableTest { } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=102631 public void test033() { - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -1246,7 +1251,17 @@ public class VarargsTest extends AbstractComparableTest { " }\n" + "}\n", }, - "112"); + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " x.a(true);\n" + + " ^\n" + + "The method a(boolean, Object[]) is ambiguous for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " x.a(true, \"foobar\");\n" + + " ^\n" + + "The method a(boolean, Object[]) is ambiguous for the type X\n" + + "----------\n"); this.runNegativeTest( new String[] { "X.java", @@ -2786,4 +2801,138 @@ public class VarargsTest extends AbstractComparableTest { "The method foo(A...) of type B is not applicable as the formal varargs element type A is not accessible here\n" + "----------\n"); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346038 + public void test070() throws Exception { + if (this.complianceLevel < ClassFileConstants.JDK1_5) return; + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void foo(int ...i) {}\n" + + " public static void foo(double...d) {}\n" + + " public static void main(String[] args) {\n" + + " foo(1, 2, 3);\n" + + " System.out.println (\"Done\");\n" + + " }\n" + + "}\n" + }, + "Done"); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346038 + public void test070a() throws Exception { + if (this.complianceLevel < ClassFileConstants.JDK1_5) return; + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static <T> void foo(int ...i) {}\n" + + " public static <T> void foo(double...d) {}\n" + + " public static void main(String[] args) {\n" + + " foo(1, 2, 3);\n" + + " System.out.println (\"Done\");\n" + + " }\n" + + "}\n" + }, + "Done"); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346038 + public void test070b() throws Exception { + if (this.complianceLevel < ClassFileConstants.JDK1_5) return; + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void foo(int ...i) {}\n" + + " public static void foo(double d1, double...d) {}\n" + + " public static void main(String[] args) {\n" + + " foo(1, 2, 3); // foo NOT flagged ambiguous\n" + + " }\n" + + "}\n" + }, + ""); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346038 + public void test070c() { // check behaviour of Scope.mostSpecificMethodBinding() + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] s) {\n" + + " count(1);\n" + + " count(1, 1);\n" + + " count(1, 1, 1);\n" + + " }\n" + + " public static void count(int ... values) {}\n" + + " public static void count(int i, int ... values) {}\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " count(1);\n" + + " ^^^^^\n" + + "The method count(int[]) is ambiguous for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " count(1, 1);\n" + + " ^^^^^\n" + + "The method count(int[]) is ambiguous for the type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " count(1, 1, 1);\n" + + " ^^^^^\n" + + "The method count(int[]) is ambiguous for the type X\n" + + "----------\n"); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346038 + public void test070d() { // check behaviour of Scope.mostSpecificMethodBinding() + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void b(boolean b, Object... o) {}\n" + + " void b(Boolean... o) {}\n" + + " void c(boolean b, boolean b2, Object... o) {}\n" + + " void c(Boolean b, Object... o) {}\n" + + " public static void main(String[] args) {\n" + + " X x = new X();\n" + + " x.b(true);\n" + + " x.b(true, false);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\r\n" + + " x.b(true);\r\n" + + " ^\n" + + "The method b(boolean, Object[]) is ambiguous for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\r\n" + + " x.b(true, false);\r\n" + + " ^\n" + + "The method b(boolean, Object[]) is ambiguous for the type X\n" + + "----------\n"); +} + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346039 + public void test071() { // check behaviour of Scope.mostSpecificMethodBinding() + this.runConformTest( + new String[] { + "X.java", + "public class X implements IClass{\n" + + " X(IClass c, X t, IType... args) {\n" + + " System.out.println (\"1\");\n" + + " }\n" + + " X(IClass c, IType... args) {\n" + + " System.out.println (\"2\");\n" + + " }\n" + + " public static void main(String args[]) {\n" + + " IClass c = null;\n" + + " X t = null;\n" + + " X t2 = new X(c, t); // incorrectly flagged ambiguous\n" + + " }\n" + + "}\n" + + "interface IType{}\n" + + "interface IClass extends IType{}\n" + }, + "1"); } +}
\ No newline at end of file |