Fix capturing of outer type parameters for classes declared inside init block
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
class Outer<T> (val v: T) {
|
||||
val prop: Any?
|
||||
|
||||
init {
|
||||
class Inner(val v: T) {
|
||||
override fun toString() = v.toString()
|
||||
}
|
||||
|
||||
val value: Inner = Inner(v)
|
||||
prop = value
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Outer("OK").prop.toString()
|
||||
}
|
||||
+5
@@ -23103,6 +23103,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt2318.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt24913.kt")
|
||||
public void testKt24913() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Kt2495Test.kt")
|
||||
public void testKt2495Test() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");
|
||||
|
||||
+5
@@ -23103,6 +23103,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/regressions/kt2318.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt24913.kt")
|
||||
public void testKt24913() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Kt2495Test.kt")
|
||||
public void testKt2495Test() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");
|
||||
|
||||
+5
@@ -22003,6 +22003,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/regressions/kt2318.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt24913.kt")
|
||||
public void testKt24913() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Kt2495Test.kt")
|
||||
public void testKt2495Test() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");
|
||||
|
||||
@@ -30,7 +30,9 @@ fun ClassifierDescriptorWithTypeParameters.computeConstructorTypeParameters(): L
|
||||
|
||||
val parametersFromContainingFunctions =
|
||||
parents.takeWhile { it is CallableDescriptor }
|
||||
.flatMap { (it as CallableDescriptor).typeParameters.asSequence() }.toList()
|
||||
.filter { it !is ConstructorDescriptor }
|
||||
.flatMap { (it as CallableDescriptor).typeParameters.asSequence() }
|
||||
.toList()
|
||||
|
||||
val containingClassTypeConstructorParameters = parents.firstIsInstanceOrNull<ClassDescriptor>()?.typeConstructor?.parameters.orEmpty()
|
||||
if (parametersFromContainingFunctions.isEmpty() && containingClassTypeConstructorParameters.isEmpty()) return declaredTypeParameters
|
||||
|
||||
Generated
+5
@@ -17753,6 +17753,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt2246.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt24913.kt")
|
||||
public void testKt24913() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Kt2495Test.kt")
|
||||
public void testKt2495Test() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");
|
||||
|
||||
+5
@@ -18908,6 +18908,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt2246.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt24913.kt")
|
||||
public void testKt24913() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Kt2495Test.kt")
|
||||
public void testKt2495Test() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");
|
||||
|
||||
Reference in New Issue
Block a user