Resolve elements in chain of qualifier expression without expected type

Consider call chain `foo.bar.baz()` which has expected type `Int`
Elements `foo` and `bar` doesn't have expected type `Int`,
this is especially important in NI, because we use expected type for
candidate applicability
This commit is contained in:
Mikhail Zarechenskiy
2018-03-29 11:35:25 +03:00
parent 3d73786e98
commit aebcb61402
6 changed files with 48 additions and 1 deletions
@@ -413,7 +413,7 @@ class CallExpressionResolver(
val currentContext = context.replaceExpectedType(NO_EXPECTED_TYPE).replaceContextDependency(INDEPENDENT)
val trace = currentContext.trace
val elementChain = expression.elementChain(context)
val elementChain = expression.elementChain(currentContext)
val firstReceiver = elementChain.first().receiver
var receiverTypeInfo = when (trace.get(BindingContext.QUALIFIER, firstReceiver)) {
@@ -0,0 +1,23 @@
// !LANGUAGE: +NewInference
// WITH_RUNTIME
// FILE: messages/foo.kt
package messages
fun foo() {}
// FILE: sample.kt
class Test {
val messages = arrayListOf<String>()
fun test(): Boolean {
return messages.any { it == "foo" }
}
}
fun box(): String {
val result = Test().test()
return if (result) "faile" else "OK"
}
@@ -14086,6 +14086,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/privateTopLevelPropAndVarInInner.kt");
doTest(fileName);
}
@TestMetadata("referenceWithTheSameNameAsPackage.kt")
public void testReferenceWithTheSameNameAsPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/referenceWithTheSameNameAsPackage.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/platformTypes")
@@ -14086,6 +14086,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/privateTopLevelPropAndVarInInner.kt");
doTest(fileName);
}
@TestMetadata("referenceWithTheSameNameAsPackage.kt")
public void testReferenceWithTheSameNameAsPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/referenceWithTheSameNameAsPackage.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/platformTypes")
@@ -14086,6 +14086,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/privateTopLevelPropAndVarInInner.kt");
doTest(fileName);
}
@TestMetadata("referenceWithTheSameNameAsPackage.kt")
public void testReferenceWithTheSameNameAsPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/referenceWithTheSameNameAsPackage.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/platformTypes")
@@ -16701,6 +16701,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/privateTopLevelPropAndVarInInner.kt");
doTest(fileName);
}
@TestMetadata("referenceWithTheSameNameAsPackage.kt")
public void testReferenceWithTheSameNameAsPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/package/referenceWithTheSameNameAsPackage.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/platformTypes")