mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
diamonds; actual types accepted in java 7 even if no formal types were defined!
(cherry picked from commit 903984b162008a56def605c72743c22517304a2d)
This commit is contained in:
+23
-1
@@ -108,4 +108,26 @@ class FI1 {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Super<X,Y> {
|
||||
private Super(Integer i, Y y, X x) {}
|
||||
public Super(Number n, X x, Y y) {}
|
||||
}
|
||||
|
||||
class TestMySuper {
|
||||
Super<String,Integer> ssi1 = new Super<>(1, "", 2);
|
||||
}
|
||||
|
||||
class TestLocal<X> {
|
||||
class Member { }
|
||||
static class Nested {}
|
||||
|
||||
void test() {
|
||||
class Local {}
|
||||
|
||||
Member m = new Member<<error descr="Diamond operator is not applicable for non-parameterized types"></error>>();
|
||||
Nested n = new Nested<<error descr="Diamond operator is not applicable for non-parameterized types"></error>>();
|
||||
Local l = new Local<<error descr="Diamond operator is not applicable for non-parameterized types"></error>>();
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Neg12 {
|
||||
|
||||
static class Foo<X> {
|
||||
<T> Foo(T t) {}
|
||||
}
|
||||
|
||||
Foo<Integer> fi1 = new <<error descr="Actual type argument and inferred type contradict each other">String</error>> Foo<>(1);
|
||||
Foo<Integer> fi2 = new <<error descr="Actual type argument and inferred type contradict each other">String</error>> Foo<Integer>(1);
|
||||
Foo<Integer> fi3 = new Foo<Integer>(1);
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Neg13 {
|
||||
|
||||
static class Foo<X> {
|
||||
<T> Foo(T t) {}
|
||||
}
|
||||
|
||||
Foo<Integer> fi1 = new <error descr="Wrong number of type arguments: 2; required: 1"><String, Integer></error> Foo<>("");
|
||||
Foo<Integer> fi2 = new <error descr="Wrong number of type arguments: 2; required: 1"><String, Integer></error> Foo<Integer>("");
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Neg14 {
|
||||
|
||||
static class Foo<X> {
|
||||
<T extends Integer> Foo(T t) {}
|
||||
}
|
||||
|
||||
Foo<Integer> fi1 = new <<error descr="Actual type argument and inferred type contradict each other">String</error>> Foo<>(1);
|
||||
Foo<Integer> fi2 = new <<error descr="Actual type argument and inferred type contradict each other">String</error>> Foo<Integer>(1);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class Pos8 {
|
||||
|
||||
static class Foo<X> {
|
||||
Foo(X t) {}
|
||||
}
|
||||
|
||||
Foo<Integer> fi1 = new Foo<>(1);
|
||||
Foo<Integer> fi2 = new Foo<Integer>(1);
|
||||
Foo<Integer> fi3 = new <String> Foo<>(1);
|
||||
Foo<Integer> fi4 = new <String> Foo<Integer>(1);
|
||||
Foo<Integer> fi5 = new <String, String> Foo<>(1);
|
||||
Foo<Integer> fi6 = new <String, String> Foo<Integer>(1);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Pos9<X> {
|
||||
|
||||
Pos9(X x) {}
|
||||
|
||||
|
||||
Pos9<X> test(X x) {
|
||||
return new Pos9<>(x);
|
||||
}
|
||||
}
|
||||
|
||||
+22
-4
@@ -68,16 +68,22 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
/*
|
||||
should be negative?
|
||||
intersection types are not allowed in <>?!
|
||||
|
||||
public void testDiamondPos6() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos7() throws Exception {
|
||||
doTest(false, false);
|
||||
}*/
|
||||
}
|
||||
|
||||
public void testDiamondPos8() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos9() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg1() throws Exception {
|
||||
doTest(false, false);
|
||||
@@ -123,6 +129,18 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg12() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg13() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg14() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondMisc() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user