[FIR] Filter out SAM constructors from MemberScopeTowerLevel
This tower level is for calls on a dispatch receiver, and it's not allowed to call SAM constructors on a dispatch receiver. #KT-60983 Fixed
This commit is contained in:
committed by
Space Team
parent
576d8d1c10
commit
907ebb36d0
+6
@@ -29218,6 +29218,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60983.kt")
|
||||||
|
public void testKt60983() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
|
|||||||
+6
@@ -29218,6 +29218,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60983.kt")
|
||||||
|
public void testKt60983() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
|
|||||||
+6
@@ -29206,6 +29206,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60983.kt")
|
||||||
|
public void testKt60983() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
|
|||||||
+6
@@ -29218,6 +29218,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60983.kt")
|
||||||
|
public void testKt60983() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
|
|||||||
+5
-5
@@ -9,10 +9,7 @@ import org.jetbrains.kotlin.KtFakeSourceElementKind
|
|||||||
import org.jetbrains.kotlin.KtSourceElement
|
import org.jetbrains.kotlin.KtSourceElement
|
||||||
import org.jetbrains.kotlin.fakeElement
|
import org.jetbrains.kotlin.fakeElement
|
||||||
import org.jetbrains.kotlin.fir.*
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.ContextReceiverGroup
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.getAnnotationByClassId
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isInner
|
import org.jetbrains.kotlin.fir.declarations.utils.isInner
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isStatic
|
import org.jetbrains.kotlin.fir.declarations.utils.isStatic
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
@@ -174,7 +171,10 @@ class MemberScopeTowerLevel(
|
|||||||
empty = false
|
empty = false
|
||||||
if (candidate.hasConsistentExtensionReceiver(givenExtensionReceiverOptions)) {
|
if (candidate.hasConsistentExtensionReceiver(givenExtensionReceiverOptions)) {
|
||||||
val fir = candidate.fir
|
val fir = candidate.fir
|
||||||
if ((fir as? FirConstructor)?.isInner == false) {
|
// Calls on a dispatch receiver cannot be:
|
||||||
|
// - a constructor call unless it's an inner class
|
||||||
|
// - a SAM constructor call
|
||||||
|
if ((fir as? FirConstructor)?.isInner == false || fir.origin == FirDeclarationOrigin.SamConstructor) {
|
||||||
return@processScopeMembers
|
return@processScopeMembers
|
||||||
}
|
}
|
||||||
result += MemberWithBaseScope(candidate, this)
|
result += MemberWithBaseScope(candidate, this)
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// MODULE: m1
|
||||||
|
// FILE: J.java
|
||||||
|
public class J {
|
||||||
|
public static class C {}
|
||||||
|
public class C2 {}
|
||||||
|
public interface I {
|
||||||
|
void x();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
class K {
|
||||||
|
open class C
|
||||||
|
inner class C2
|
||||||
|
fun interface I {
|
||||||
|
fun x()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun J.testJ() {
|
||||||
|
<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
C2()
|
||||||
|
<!UNRESOLVED_REFERENCE!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testJ2(j: J) {
|
||||||
|
j.<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
j.C2()
|
||||||
|
j.<!UNRESOLVED_REFERENCE!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun K.testK() {
|
||||||
|
<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
C2()
|
||||||
|
<!UNRESOLVED_REFERENCE!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testK2(k: K) {
|
||||||
|
k.<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
k.C2()
|
||||||
|
k.<!UNRESOLVED_REFERENCE!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: m2(m1)
|
||||||
|
// FILE: testResolutionContinues.kt
|
||||||
|
fun J.testResolutionContinues() {
|
||||||
|
acceptI(I {})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun K.testResolutionContinues() {
|
||||||
|
acceptI(I {})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interface I {
|
||||||
|
fun x()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun acceptI(i: I) {}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// MODULE: m1
|
||||||
|
// FILE: J.java
|
||||||
|
public class J {
|
||||||
|
public static class C {}
|
||||||
|
public class C2 {}
|
||||||
|
public interface I {
|
||||||
|
void x();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
class K {
|
||||||
|
open class C
|
||||||
|
inner class C2
|
||||||
|
fun interface I {
|
||||||
|
fun x()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun J.testJ() {
|
||||||
|
<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
C2()
|
||||||
|
<!UNRESOLVED_REFERENCE!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testJ2(j: J) {
|
||||||
|
j.<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
j.C2()
|
||||||
|
j.<!RESOLUTION_TO_CLASSIFIER!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun K.testK() {
|
||||||
|
<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
C2()
|
||||||
|
<!UNRESOLVED_REFERENCE!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testK2(k: K) {
|
||||||
|
k.<!UNRESOLVED_REFERENCE!>C<!>()
|
||||||
|
k.C2()
|
||||||
|
k.<!RESOLUTION_TO_CLASSIFIER!>I<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: m2(m1)
|
||||||
|
// FILE: testResolutionContinues.kt
|
||||||
|
fun J.testResolutionContinues() {
|
||||||
|
acceptI(I {})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun K.testResolutionContinues() {
|
||||||
|
acceptI(I {})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun interface I {
|
||||||
|
fun x()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun acceptI(i: I) {}
|
||||||
Generated
+6
@@ -31152,6 +31152,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt50477.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60983.kt")
|
||||||
|
public void testKt60983() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user