[NI] fix approximation of not denotable types in lambda's function descriptors

This commit is contained in:
Dmitriy Novozhilov
2019-03-26 13:48:44 +03:00
parent a9de157fd4
commit 4a1b9dcc3c
5 changed files with 40 additions and 1 deletions
@@ -133,7 +133,13 @@ class ResolvedAtomCompleter(
resultSubstitutor.safeSubstitute(lambda.returnType)
}
updateTraceForLambda(lambda, topLevelTrace, returnType)
val approximatedReturnType =
TypeApproximator().approximateDeclarationType(
returnType,
local = true,
languageVersionSettings = topLevelCallContext.languageVersionSettings
)
updateTraceForLambda(lambda, topLevelTrace, approximatedReturnType)
for (lambdaResult in lambda.resultArguments) {
val resultValueArgument = lambdaResult as? PSIKotlinCallArgument ?: continue
@@ -0,0 +1,18 @@
// !LANGUAGE: +NewInference
// TARGET_BACKEND: JVM
// WITH_RUNTIME
class Foo<C : Any> {
fun test(candidates: Collection<C>): List<C> {
return candidates.sortedBy { 1 }
}
}
fun box(): String {
val foo = Foo<String>()
val list = listOf("OK")
val sorted = foo.test(list)
return list.first()
}
@@ -11870,6 +11870,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("integerLiteralTypeInLamdaReturnType.kt")
public void testIntegerLiteralTypeInLamdaReturnType() throws Exception {
runTest("compiler/testData/codegen/box/inference/integerLiteralTypeInLamdaReturnType.kt");
}
@TestMetadata("kt10822.kt")
public void testKt10822() throws Exception {
runTest("compiler/testData/codegen/box/inference/kt10822.kt");
@@ -11870,6 +11870,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("integerLiteralTypeInLamdaReturnType.kt")
public void testIntegerLiteralTypeInLamdaReturnType() throws Exception {
runTest("compiler/testData/codegen/box/inference/integerLiteralTypeInLamdaReturnType.kt");
}
@TestMetadata("kt10822.kt")
public void testKt10822() throws Exception {
runTest("compiler/testData/codegen/box/inference/kt10822.kt");
@@ -11875,6 +11875,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("integerLiteralTypeInLamdaReturnType.kt")
public void testIntegerLiteralTypeInLamdaReturnType() throws Exception {
runTest("compiler/testData/codegen/box/inference/integerLiteralTypeInLamdaReturnType.kt");
}
@TestMetadata("kt10822.kt")
public void testKt10822() throws Exception {
runTest("compiler/testData/codegen/box/inference/kt10822.kt");