Skip to content

Commit 3e2a88e

Browse files
committed
reproduce the issue
1 parent b160bbb commit 3e2a88e

File tree

4 files changed

+207
-0
lines changed

4 files changed

+207
-0
lines changed

tests/run/i19619/InnerClass.java

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// InnerClass.java
2+
3+
package lib;
4+
5+
public class InnerClass {
6+
7+
public class Inner<U> {
8+
public U innerField;
9+
10+
public Inner(U innerField) {
11+
this.innerField = innerField;
12+
}
13+
14+
public U getInnerField() {
15+
return innerField;
16+
}
17+
}
18+
19+
public class Outer<U> {
20+
21+
public class Nested<V> {
22+
23+
public U outerField;
24+
public V innerField;
25+
26+
public Nested(U outerField, V innerField) {
27+
this.outerField = outerField;
28+
this.innerField = innerField;
29+
}
30+
31+
public U getOuterField() {
32+
return outerField;
33+
}
34+
35+
public V getInnerField() {
36+
return innerField;
37+
}
38+
}
39+
}
40+
41+
public <U> Inner<U> createInner(U innerField) {
42+
return new Inner<>(innerField);
43+
}
44+
45+
public <U, V> Outer<U>.Nested<V> createNested(U outerField, V innerField) {
46+
Outer<U> outer = new Outer<>();
47+
return outer.new Nested<>(outerField, innerField);
48+
}
49+
50+
public static <U> InnerClass.Inner<U> createInnerStatic(U innerField) {
51+
InnerClass innerClass = new InnerClass();
52+
return innerClass.new Inner<>(innerField);
53+
}
54+
55+
public static <U, V> InnerClass.Outer<U>.Nested<V> createNestedStatic(U outerField, V innerField) {
56+
InnerClass innerClass = new InnerClass();
57+
InnerClass.Outer<U> outer = innerClass.new Outer<>();
58+
return outer.new Nested<>(outerField, innerField);
59+
}
60+
61+
public static <U, V> void consumeNestedStatic(InnerClass.Outer<U>.Nested<V> nested) {
62+
}
63+
64+
public static <U, V> void consumeNestedStatic2(Outer<U>.Nested<V> nested) {
65+
}
66+
67+
}

tests/run/i19619/InnerClassGen.java

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// InnerClassGen.java
2+
3+
package lib;
4+
5+
public class InnerClassGen<T> {
6+
7+
public class Inner<U> {
8+
public T rootField;
9+
public U innerField;
10+
11+
public Inner(T rootField, U innerField) {
12+
this.rootField = rootField;
13+
this.innerField = innerField;
14+
}
15+
16+
public T getRootField() {
17+
return rootField;
18+
}
19+
20+
public U getInnerField() {
21+
return innerField;
22+
}
23+
}
24+
25+
public class Outer<U> {
26+
27+
public class Nested<V> {
28+
public T rootField;
29+
public U outerField;
30+
public V innerField;
31+
32+
public Nested(T rootField, U outerField, V innerField) {
33+
this.rootField = rootField;
34+
this.outerField = outerField;
35+
this.innerField = innerField;
36+
}
37+
38+
public T getRootField() {
39+
return rootField;
40+
}
41+
42+
public U getOuterField() {
43+
return outerField;
44+
}
45+
46+
public V getInnerField() {
47+
return innerField;
48+
}
49+
}
50+
}
51+
52+
public static class OuterStatic<U> {
53+
public static class NestedStatic<V> {
54+
}
55+
}
56+
57+
public <U> Inner<U> createInner(T rootField, U innerField) {
58+
return new Inner<>(rootField, innerField);
59+
}
60+
61+
public <U, V> Outer<U>.Nested<V> createNested(T rootField, U outerField, V innerField) {
62+
Outer<U> outer = new Outer<>();
63+
return outer.new Nested<>(rootField, outerField, innerField);
64+
}
65+
66+
public static <T, U> InnerClassGen<T>.Inner<U> createInnerStatic(T rootField, U innerField) {
67+
InnerClassGen<T> innerClassGen = new InnerClassGen<>();
68+
return innerClassGen.new Inner<>(rootField, innerField);
69+
}
70+
71+
public static <T, U, V> InnerClassGen<T>.Outer<U>.Nested<V> createNestedStatic(T rootField, U outerField, V innerField) {
72+
InnerClassGen<T> innerClassGen = new InnerClassGen<>();
73+
InnerClassGen<T>.Outer<U> outer = innerClassGen.new Outer<>();
74+
return outer.new Nested<>(rootField, outerField, innerField);
75+
}
76+
77+
public static <T, U, V> void consumeNestedStatic(InnerClassGen<T>.Outer<U>.Nested<V> nested) {
78+
}
79+
80+
}

tests/run/i19619/RawTypes.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RawTypes.java
2+
3+
package lib;
4+
5+
public class RawTypes {
6+
7+
public class C<T> {
8+
public class D<U> {
9+
}
10+
}
11+
12+
public static void mii_Raw_Raw(RawTypes.C.D d) {
13+
}
14+
15+
public static void mii_Raw_Raw2(C.D d) {
16+
}
17+
18+
}

tests/run/i19619/Test.scala

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import lib.InnerClass
2+
import lib.InnerClassGen
3+
import lib.RawTypes
4+
5+
@main def Test =
6+
7+
locally:
8+
val ici: InnerClass = new InnerClass()
9+
val ici_inner1: ici.Inner[Long] = ici.createInner[Long](47L) // ok, but should error
10+
val ici_inner2: InnerClass#Inner[Long] = ici.createInner[Long](47L)
11+
val ici_inner3: InnerClass#Inner[Long] = InnerClass.createInnerStatic[Long](47L)
12+
13+
val ici_outer: InnerClass#Outer[Long] = new ici.Outer[Long]()
14+
val ici_nested1: InnerClass#Outer[Long]#Nested[Int] = new ici_outer.Nested[Int](47L, 23)
15+
val ici_nested2: InnerClass#Outer[Long]#Nested[Int] = ici.createNested[Long, Int](47L, 23)
16+
val ici_nested3: InnerClass#Outer[Long]#Nested[Int] = InnerClass.createNestedStatic[Long, Int](47L, 23)
17+
18+
InnerClass.consumeNestedStatic(ici_nested3)
19+
InnerClass.consumeNestedStatic2(ici_nested3) // error: dotty is inferring static selection when there is no explicit prefix
20+
21+
locally:
22+
val ici: InnerClassGen[String] = new InnerClassGen()
23+
val ici_inner1: ici.Inner[Long] = ici.createInner[Long]("Hello", 47L) // ok, but should error
24+
val ici_inner2: InnerClassGen[String]#Inner[Long] = ici.createInner[Long]("Hello", 47L)
25+
val ici_inner3: InnerClassGen[String]#Inner[Long] = InnerClassGen.createInnerStatic[String, Long]("Hello", 47L)
26+
27+
val ici_outer: InnerClassGen[String]#Outer[Long] = new ici.Outer[Long]()
28+
val ici_nested1: InnerClassGen[String]#Outer[Long]#Nested[Int] = new ici_outer.Nested[Int]("Hello", 47L, 23)
29+
val ici_nested2: InnerClassGen[String]#Outer[Long]#Nested[Int] = ici.createNested[Long, Int]("Hello", 47L, 23)
30+
val ici_nested3: InnerClassGen[String]#Outer[Long]#Nested[Int] = InnerClassGen.createNestedStatic[String, Long, Int]("Hello", 47L, 23)
31+
32+
InnerClassGen.consumeNestedStatic(ici_nested3)
33+
34+
locally:
35+
val rt: RawTypes = new RawTypes()
36+
val c: RawTypes#C[String] = new rt.C[String]()
37+
38+
val cd_ii: RawTypes#C[String]#D[String] = new c.D[String]()
39+
val cd_ii_Raw: RawTypes#C[?]#D[?] = cd_ii
40+
41+
RawTypes.mii_Raw_Raw(cd_ii_Raw)
42+
RawTypes.mii_Raw_Raw2(cd_ii_Raw) // error: dotty is inferring static selection when there is no explicit prefix

0 commit comments

Comments
 (0)