NI: don't collect members if a receiver type is StubType to avoid creating error candidates instead of not crating them at all

^KT-37717 Fixed
This commit is contained in:
Victor Petukhov
2020-07-06 11:06:34 +03:00
parent 989e4293a3
commit eec3a4720c
11 changed files with 79 additions and 2 deletions
@@ -10409,6 +10409,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/returningLambdaInSuspendContext.kt");
}
@TestMetadata("skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt")
public void testSkipedUnresolvedInBuilderInferenceWithStubReceiverType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt");
}
@TestMetadata("starApproximation.kt")
public void testStarApproximation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/starApproximation.kt");
@@ -90,8 +90,14 @@ internal class MemberScopeTowerLevel(
private fun collectMembers(
getMembers: ResolutionScope.(KotlinType?) -> Collection<CallableDescriptor>
): Collection<CandidateWithBoundDispatchReceiver> {
val result = ArrayList<CandidateWithBoundDispatchReceiver>(0)
val receiverValue = dispatchReceiver.receiverValue
if (receiverValue.type is StubType) {
return arrayListOf()
}
val result = ArrayList<CandidateWithBoundDispatchReceiver>(0)
receiverValue.type.memberScope.getMembers(receiverValue.type).mapTo(result) {
createCandidateDescriptor(it, dispatchReceiver)
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
import kotlin.experimental.ExperimentalTypeInference
@OptIn(ExperimentalTypeInference::class)
fun <T> foo(x: T, @BuilderInference builder: T.() -> Unit): Unit = TODO()
class Bar<T>
fun test() {
foo(1) {
<!UNRESOLVED_REFERENCE!>dsgfsdg<!>
}
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
import kotlin.experimental.ExperimentalTypeInference
@OptIn(ExperimentalTypeInference::class)
fun <T> foo(x: T, @BuilderInference builder: T.() -> Unit): Unit = TODO()
class Bar<T>
fun test() {
foo(1) {
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>dsgfsdg<!>
}
}
@@ -0,0 +1,11 @@
package
@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ T> foo(/*0*/ x: T, /*1*/ @kotlin.BuilderInference builder: T.() -> kotlin.Unit): kotlin.Unit
public fun test(): kotlin.Unit
public final class Bar</*0*/ T> {
public constructor Bar</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -15,6 +15,6 @@ fun <KotlinType : Any> defineType(@BuilderInference definition: TypeDefinition<K
fun main() {
<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>defineType<!> {
parse { it.toInt() }
serialize { <!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>toString<!>() }
serialize { <!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!>.<!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>toString<!>() }
}
}
@@ -10416,6 +10416,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
runTest("compiler/testData/diagnostics/tests/inference/returningLambdaInSuspendContext.kt");
}
@TestMetadata("skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt")
public void testSkipedUnresolvedInBuilderInferenceWithStubReceiverType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt");
}
@TestMetadata("starApproximation.kt")
public void testStarApproximation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/starApproximation.kt");
@@ -10411,6 +10411,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/inference/returningLambdaInSuspendContext.kt");
}
@TestMetadata("skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt")
public void testSkipedUnresolvedInBuilderInferenceWithStubReceiverType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt");
}
@TestMetadata("starApproximation.kt")
public void testStarApproximation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/starApproximation.kt");
@@ -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("constValInAnnotation.kt")
public void testConstValInAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt");
}
@TestMetadata("nestedAnnotation.kt")
public void testNestedAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
@@ -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("constValInAnnotation.kt")
public void testConstValInAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt");
}
@TestMetadata("nestedAnnotation.kt")
public void testNestedAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
@@ -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("constValInAnnotation.kt")
public void testConstValInAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt");
}
@TestMetadata("nestedAnnotation.kt")
public void testNestedAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");