NI: approximate not top-level captured types during code generation
^KT-40693 Fixed
This commit is contained in:
@@ -2835,7 +2835,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
TypeApproximator approximator = new TypeApproximator(state.getModule().getBuiltIns());
|
||||
|
||||
KotlinType approximatedType =
|
||||
CapturedTypeConstructorKt.isCaptured(type) ?
|
||||
TypeUtils.contains(type, (containedType) -> CapturedTypeConstructorKt.isCaptured(containedType)) ?
|
||||
(KotlinType) approximator.approximateToSuperType(
|
||||
type, TypeApproximatorConfiguration.InternalTypesApproximation.INSTANCE
|
||||
) : null;
|
||||
|
||||
Generated
+5
@@ -12414,6 +12414,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximateNonTopLevelCapturedTypes.kt")
|
||||
public void testApproximateNonTopLevelCapturedTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInference.kt")
|
||||
public void testBuilderInference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
interface BasePublisher<U>
|
||||
|
||||
interface Flow<out P>
|
||||
|
||||
fun <R> asFlow(x: BasePublisher<R>): Flow<R> = null as Flow<R>
|
||||
|
||||
class Document<S>
|
||||
|
||||
interface DerivedPublisher<K>: BasePublisher<Document<K>> {}
|
||||
|
||||
class Foo<T>(val x: DerivedPublisher<out T>) : Flow<Document<out T>> by asFlow(x)
|
||||
|
||||
fun box() = "OK"
|
||||
+5
@@ -13639,6 +13639,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximateNonTopLevelCapturedTypes.kt")
|
||||
public void testApproximateNonTopLevelCapturedTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInference.kt")
|
||||
public void testBuilderInference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||
|
||||
+5
@@ -13639,6 +13639,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximateNonTopLevelCapturedTypes.kt")
|
||||
public void testApproximateNonTopLevelCapturedTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInference.kt")
|
||||
public void testBuilderInference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||
|
||||
+5
@@ -12414,6 +12414,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximateNonTopLevelCapturedTypes.kt")
|
||||
public void testApproximateNonTopLevelCapturedTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInference.kt")
|
||||
public void testBuilderInference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||
|
||||
Generated
+10
@@ -41,6 +41,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/annotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedObjectLiteral.kt")
|
||||
public void testAnnotatedObjectLiteral() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/annotatedObjectLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
@@ -10689,6 +10694,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximateNonTopLevelCapturedTypes.kt")
|
||||
public void testApproximateNonTopLevelCapturedTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||
|
||||
Generated
+10
@@ -41,6 +41,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/annotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedObjectLiteral.kt")
|
||||
public void testAnnotatedObjectLiteral() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/annotatedObjectLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
@@ -10689,6 +10694,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximateNonTopLevelCapturedTypes.kt")
|
||||
public void testApproximateNonTopLevelCapturedTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||
|
||||
+10
@@ -41,6 +41,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/annotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedObjectLiteral.kt")
|
||||
public void testAnnotatedObjectLiteral() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/annotatedObjectLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
@@ -10754,6 +10759,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximateNonTopLevelCapturedTypes.kt")
|
||||
public void testApproximateNonTopLevelCapturedTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/approximateNonTopLevelCapturedTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||
|
||||
Reference in New Issue
Block a user