[NI] Avoid type capturing for types that can contain type variables
This commit is contained in:
committed by
Stanislav Erokhin
parent
e040a317cc
commit
08964006de
@@ -224,7 +224,9 @@ internal fun createSimplePSICallArgument(
|
|||||||
ownerDescriptor, bindingContext,
|
ownerDescriptor, bindingContext,
|
||||||
typeInfoForArgument.dataFlowInfo, // dataFlowInfoBeforeThisArgument cannot be used here, because of if() { if (x != null) return; x }
|
typeInfoForArgument.dataFlowInfo, // dataFlowInfoBeforeThisArgument cannot be used here, because of if() { if (x != null) return; x }
|
||||||
ExpressionReceiver.create(ktExpression, baseType, bindingContext)
|
ExpressionReceiver.create(ktExpression, baseType, bindingContext)
|
||||||
).prepareReceiverRegardingCaptureTypes()
|
).let {
|
||||||
|
if (onlyResolvedCall == null) it.prepareReceiverRegardingCaptureTypes() else it
|
||||||
|
}
|
||||||
|
|
||||||
return if (onlyResolvedCall == null) {
|
return if (onlyResolvedCall == null) {
|
||||||
ExpressionKotlinCallArgumentImpl(valueArgument, dataFlowInfoBeforeThisArgument, typeInfoForArgument.dataFlowInfo, receiverToCast)
|
ExpressionKotlinCallArgumentImpl(valueArgument, dataFlowInfoBeforeThisArgument, typeInfoForArgument.dataFlowInfo, receiverToCast)
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
fun test(i: Inv<out Any?>) {
|
||||||
|
foo(i.superclass())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> foo(x: T) {}
|
||||||
|
|
||||||
|
class Inv<T>
|
||||||
|
|
||||||
|
fun <T> Inv<T>.superclass(): Inv<in T> = Inv()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
test(Inv())
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
fun foo(useScriptArgs: Array<out Any?>?) {
|
||||||
|
val constructorArgs: Array<out Any?> = arrayOf(useScriptArgs.orEmpty())
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
foo(arrayOf(1))
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+12
@@ -16580,6 +16580,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dontCaptureTypesWithTypeVariables.kt")
|
||||||
|
public void testDontCaptureTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("doubleMerge.kt")
|
@TestMetadata("doubleMerge.kt")
|
||||||
public void testDoubleMerge() throws Exception {
|
public void testDoubleMerge() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
||||||
@@ -16976,6 +16982,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noCapturingForTypesWithTypeVariables.kt")
|
||||||
|
public void testNoCapturingForTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noResolutionRecursion.kt")
|
@TestMetadata("noResolutionRecursion.kt")
|
||||||
public void testNoResolutionRecursion() throws Exception {
|
public void testNoResolutionRecursion() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
||||||
|
|||||||
@@ -16580,6 +16580,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dontCaptureTypesWithTypeVariables.kt")
|
||||||
|
public void testDontCaptureTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("doubleMerge.kt")
|
@TestMetadata("doubleMerge.kt")
|
||||||
public void testDoubleMerge() throws Exception {
|
public void testDoubleMerge() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
||||||
@@ -16976,6 +16982,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noCapturingForTypesWithTypeVariables.kt")
|
||||||
|
public void testNoCapturingForTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noResolutionRecursion.kt")
|
@TestMetadata("noResolutionRecursion.kt")
|
||||||
public void testNoResolutionRecursion() throws Exception {
|
public void testNoResolutionRecursion() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
||||||
|
|||||||
@@ -16580,6 +16580,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dontCaptureTypesWithTypeVariables.kt")
|
||||||
|
public void testDontCaptureTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("doubleMerge.kt")
|
@TestMetadata("doubleMerge.kt")
|
||||||
public void testDoubleMerge() throws Exception {
|
public void testDoubleMerge() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
||||||
@@ -16976,6 +16982,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noCapturingForTypesWithTypeVariables.kt")
|
||||||
|
public void testNoCapturingForTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noResolutionRecursion.kt")
|
@TestMetadata("noResolutionRecursion.kt")
|
||||||
public void testNoResolutionRecursion() throws Exception {
|
public void testNoResolutionRecursion() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
||||||
|
|||||||
+12
@@ -20228,6 +20228,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dontCaptureTypesWithTypeVariables.kt")
|
||||||
|
public void testDontCaptureTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("doubleMerge.kt")
|
@TestMetadata("doubleMerge.kt")
|
||||||
public void testDoubleMerge() throws Exception {
|
public void testDoubleMerge() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/doubleMerge.kt");
|
||||||
@@ -20750,6 +20756,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noCapturingForTypesWithTypeVariables.kt")
|
||||||
|
public void testNoCapturingForTypesWithTypeVariables() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noResolutionRecursion.kt")
|
@TestMetadata("noResolutionRecursion.kt")
|
||||||
public void testNoResolutionRecursion() throws Exception {
|
public void testNoResolutionRecursion() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/noResolutionRecursion.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user