[FIR] Add test for inner class type parameter capturing

This commit is contained in:
simon.ogorodnik
2020-04-09 22:28:39 +03:00
parent b72d0957e4
commit 21ede8b745
4 changed files with 68 additions and 0 deletions
@@ -0,0 +1,21 @@
class Outer<T> {
inner class Inner<K>
}
class Boxed<Q> {
fun substitute() = Outer<Q>().Inner<Int>()
}
fun accept(p: Outer<String>.Inner<Int>) {}
val rr = Outer<String>().Inner<Int>()
val rrq = Boxed<String>().substitute()
fun check() {
<!INAPPLICABLE_CANDIDATE!>accept<!>(Outer<Int>().Inner<Int>()) // illegal
<!INAPPLICABLE_CANDIDATE!>accept<!>(Outer<String>().Inner<String>()) // illegal
accept(Outer<String>().Inner<Int>()) // ok
<!INAPPLICABLE_CANDIDATE!>accept<!>(Boxed<Int>().substitute()) // illegal
accept(Boxed<String>().substitute()) // ok
}
@@ -0,0 +1,37 @@
FILE: innerTypes.kt
public final class Outer<T> : R|kotlin/Any| {
public constructor<T>(): R|Outer<T>| {
super<R|kotlin/Any|>()
}
public final inner class Inner<T, K> : R|kotlin/Any| {
public constructor<K>(): R|Outer.Inner<T, K>| {
super<R|kotlin/Any|>()
}
}
}
public final class Boxed<Q> : R|kotlin/Any| {
public constructor<Q>(): R|Boxed<Q>| {
super<R|kotlin/Any|>()
}
public final fun substitute(): R|Outer.Inner<Q, kotlin/Int>| {
^substitute R|/Outer.Outer|<R|Q|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>()
}
}
public final fun accept(p: R|Outer.Inner<kotlin/String, kotlin/Int>|): R|kotlin/Unit| {
}
public final val rr: R|Outer.Inner<kotlin/String, kotlin/Int>| = R|/Outer.Outer|<R|kotlin/String|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>()
public get(): R|Outer.Inner<kotlin/String, kotlin/Int>|
public final val rrq: R|Outer.Inner<kotlin/String, kotlin/Int>| = R|/Boxed.Boxed|<R|kotlin/String|>().R|FakeOverride</Boxed.substitute: R|Outer.Inner<kotlin/String, kotlin/Int>|>|()
public get(): R|Outer.Inner<kotlin/String, kotlin/Int>|
public final fun check(): R|kotlin/Unit| {
<Inapplicable(INAPPLICABLE): [/accept]>#(R|/Outer.Outer|<R|kotlin/Int|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>())
<Inapplicable(INAPPLICABLE): [/accept]>#(R|/Outer.Outer|<R|kotlin/String|>().R|/Outer.Inner.Inner|<R|kotlin/String|>())
R|/accept|(R|/Outer.Outer|<R|kotlin/String|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>())
<Inapplicable(INAPPLICABLE): [/accept]>#(R|/Boxed.Boxed|<R|kotlin/Int|>().R|FakeOverride</Boxed.substitute: R|Outer.Inner<kotlin/Int, kotlin/Int>|>|())
R|/accept|(R|/Boxed.Boxed|<R|kotlin/String|>().R|FakeOverride</Boxed.substitute: R|Outer.Inner<kotlin/String, kotlin/Int>|>|())
}
@@ -1495,6 +1495,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest("compiler/fir/analysis-tests/testData/resolve/nested/inner.kt");
}
@TestMetadata("innerTypes.kt")
public void testInnerTypes() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/nested/simple.kt");
@@ -1495,6 +1495,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/nested/inner.kt");
}
@TestMetadata("innerTypes.kt")
public void testInnerTypes() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/nested/simple.kt");