-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Fix java typer problems with inner class references and raw…
… types" to LTS (#20934) Backports #19747 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
13 changed files
with
484 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// InnerClass.java | ||
|
||
package lib; | ||
|
||
public class InnerClass { | ||
|
||
public class Inner<U> { | ||
public U innerField; | ||
|
||
public Inner(U innerField) { | ||
this.innerField = innerField; | ||
} | ||
|
||
public U getInnerField() { | ||
return innerField; | ||
} | ||
} | ||
|
||
public class Outer<U> { | ||
|
||
public class Nested<V> { | ||
|
||
public U outerField; | ||
public V innerField; | ||
|
||
public Nested(U outerField, V innerField) { | ||
this.outerField = outerField; | ||
this.innerField = innerField; | ||
} | ||
|
||
public U getOuterField() { | ||
return outerField; | ||
} | ||
|
||
public V getInnerField() { | ||
return innerField; | ||
} | ||
} | ||
} | ||
|
||
public <U> Inner<U> createInner(U innerField) { | ||
return new Inner<>(innerField); | ||
} | ||
|
||
public <U, V> Outer<U>.Nested<V> createNested(U outerField, V innerField) { | ||
Outer<U> outer = new Outer<>(); | ||
return outer.new Nested<>(outerField, innerField); | ||
} | ||
|
||
public static <U> InnerClass.Inner<U> createInnerStatic(U innerField) { | ||
InnerClass innerClass = new InnerClass(); | ||
return innerClass.new Inner<>(innerField); | ||
} | ||
|
||
public static <U, V> InnerClass.Outer<U>.Nested<V> createNestedStatic(U outerField, V innerField) { | ||
InnerClass innerClass = new InnerClass(); | ||
InnerClass.Outer<U> outer = innerClass.new Outer<>(); | ||
return outer.new Nested<>(outerField, innerField); | ||
} | ||
|
||
public static <U, V> void consumeNestedStatic(InnerClass.Outer<U>.Nested<V> nested) { | ||
} | ||
|
||
public static <U, V> void consumeNestedStatic2(Outer<U>.Nested<V> nested) { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// InnerClassGen.java | ||
|
||
package lib; | ||
|
||
public class InnerClassGen<T> { | ||
|
||
public class Inner<U> { | ||
public T rootField; | ||
public U innerField; | ||
|
||
public Inner(T rootField, U innerField) { | ||
this.rootField = rootField; | ||
this.innerField = innerField; | ||
} | ||
|
||
public T getRootField() { | ||
return rootField; | ||
} | ||
|
||
public U getInnerField() { | ||
return innerField; | ||
} | ||
} | ||
|
||
public class Outer<U> { | ||
|
||
public class Nested<V> { | ||
public T rootField; | ||
public U outerField; | ||
public V innerField; | ||
|
||
public Nested(T rootField, U outerField, V innerField) { | ||
this.rootField = rootField; | ||
this.outerField = outerField; | ||
this.innerField = innerField; | ||
} | ||
|
||
public T getRootField() { | ||
return rootField; | ||
} | ||
|
||
public U getOuterField() { | ||
return outerField; | ||
} | ||
|
||
public V getInnerField() { | ||
return innerField; | ||
} | ||
} | ||
} | ||
|
||
public static class OuterStatic<U> { | ||
public static class NestedStatic<V> { | ||
} | ||
} | ||
|
||
public <U> Inner<U> createInner(T rootField, U innerField) { | ||
return new Inner<>(rootField, innerField); | ||
} | ||
|
||
public <U, V> Outer<U>.Nested<V> createNested(T rootField, U outerField, V innerField) { | ||
Outer<U> outer = new Outer<>(); | ||
return outer.new Nested<>(rootField, outerField, innerField); | ||
} | ||
|
||
public static <T, U> InnerClassGen<T>.Inner<U> createInnerStatic(T rootField, U innerField) { | ||
InnerClassGen<T> innerClassGen = new InnerClassGen<>(); | ||
return innerClassGen.new Inner<>(rootField, innerField); | ||
} | ||
|
||
public static <T, U, V> InnerClassGen<T>.Outer<U>.Nested<V> createNestedStatic(T rootField, U outerField, V innerField) { | ||
InnerClassGen<T> innerClassGen = new InnerClassGen<>(); | ||
InnerClassGen<T>.Outer<U> outer = innerClassGen.new Outer<>(); | ||
return outer.new Nested<>(rootField, outerField, innerField); | ||
} | ||
|
||
public static <T, U, V> void consumeNestedStatic(InnerClassGen<T>.Outer<U>.Nested<V> nested) { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import lib.InnerClass | ||
import lib.InnerClassGen | ||
|
||
@main def Test = | ||
|
||
locally: | ||
val ici: InnerClass = new InnerClass() | ||
val ici_inner1: ici.Inner[Long] = ici.createInner[Long](47L) // error | ||
|
||
locally: | ||
val ici: InnerClassGen[String] = new InnerClassGen() | ||
val ici_inner1: ici.Inner[Long] = ici.createInner[Long]("Hello", 47L) // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// InnerClass.java | ||
|
||
package lib; | ||
|
||
public class InnerClass { | ||
|
||
public class Inner<U> { | ||
public U innerField; | ||
|
||
public Inner(U innerField) { | ||
this.innerField = innerField; | ||
} | ||
|
||
public U getInnerField() { | ||
return innerField; | ||
} | ||
} | ||
|
||
public class Outer<U> { | ||
|
||
public class Nested<V> { | ||
|
||
public U outerField; | ||
public V innerField; | ||
|
||
public Nested(U outerField, V innerField) { | ||
this.outerField = outerField; | ||
this.innerField = innerField; | ||
} | ||
|
||
public U getOuterField() { | ||
return outerField; | ||
} | ||
|
||
public V getInnerField() { | ||
return innerField; | ||
} | ||
} | ||
} | ||
|
||
public <U> Inner<U> createInner(U innerField) { | ||
return new Inner<>(innerField); | ||
} | ||
|
||
public <U, V> Outer<U>.Nested<V> createNested(U outerField, V innerField) { | ||
Outer<U> outer = new Outer<>(); | ||
return outer.new Nested<>(outerField, innerField); | ||
} | ||
|
||
public static <U> InnerClass.Inner<U> createInnerStatic(U innerField) { | ||
InnerClass innerClass = new InnerClass(); | ||
return innerClass.new Inner<>(innerField); | ||
} | ||
|
||
public static <U, V> InnerClass.Outer<U>.Nested<V> createNestedStatic(U outerField, V innerField) { | ||
InnerClass innerClass = new InnerClass(); | ||
InnerClass.Outer<U> outer = innerClass.new Outer<>(); | ||
return outer.new Nested<>(outerField, innerField); | ||
} | ||
|
||
public static <U, V> void consumeNestedStatic(InnerClass.Outer<U>.Nested<V> nested) { | ||
} | ||
|
||
public static <U, V> void consumeNestedStatic2(Outer<U>.Nested<V> nested) { | ||
} | ||
|
||
} |
Oops, something went wrong.