[FIR] Remove usage of FirSamResolver in call conflict resolution
#KT-63703 Fixed
This commit is contained in:
committed by
Space Team
parent
ad8d4051b8
commit
50bfd19959
+6
@@ -32470,6 +32470,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleSamConversionConflictResolution.kt")
|
||||
public void testMultipleSamConversionConflictResolution() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/multipleSamConversionConflictResolution.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OverloadPriority.kt")
|
||||
public void testOverloadPriority() throws Exception {
|
||||
|
||||
+6
@@ -32470,6 +32470,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleSamConversionConflictResolution.kt")
|
||||
public void testMultipleSamConversionConflictResolution() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/multipleSamConversionConflictResolution.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OverloadPriority.kt")
|
||||
public void testOverloadPriority() throws Exception {
|
||||
|
||||
+6
@@ -30304,6 +30304,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleSamConversionConflictResolution.kt")
|
||||
public void testMultipleSamConversionConflictResolution() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/multipleSamConversionConflictResolution.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OverloadPriority.kt")
|
||||
public void testOverloadPriority() throws Exception {
|
||||
|
||||
+6
@@ -30316,6 +30316,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleSamConversionConflictResolution.kt")
|
||||
public void testMultipleSamConversionConflictResolution() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/multipleSamConversionConflictResolution.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OverloadPriority.kt")
|
||||
public void testOverloadPriority() throws Exception {
|
||||
|
||||
+12
-7
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
||||
import org.jetbrains.kotlin.fir.expressions.unwrapArgument
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSamResolver
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.results.*
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.requireOrDescribe
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
|
||||
abstract class AbstractConeCallConflictResolver(
|
||||
@@ -39,8 +40,6 @@ abstract class AbstractConeCallConflictResolver(
|
||||
private val considerMissingArgumentsInSignatures: Boolean,
|
||||
) : ConeCallConflictResolver() {
|
||||
|
||||
private val samResolver: FirSamResolver get() = transformerComponents.samResolver
|
||||
|
||||
/**
|
||||
* Returns `true` if [call1] is definitely more or equally specific [call2],
|
||||
* `false` otherwise.
|
||||
@@ -212,12 +211,18 @@ abstract class AbstractConeCallConflictResolver(
|
||||
|
||||
private fun FirValueParameter.toTypeWithConversion(session: FirSession, call: Candidate): TypeWithConversion {
|
||||
val argumentType = argumentType().fullyExpandedType(session)
|
||||
return if (!call.usesSAM) {
|
||||
val functionTypeForSam = toFunctionTypeForSamOrNull(call)
|
||||
return if (functionTypeForSam == null) {
|
||||
TypeWithConversion(argumentType)
|
||||
} else {
|
||||
val functionType = samResolver.getFunctionTypeForPossibleSamType(argumentType)
|
||||
if (functionType == null) TypeWithConversion(argumentType)
|
||||
else TypeWithConversion(functionType, argumentType)
|
||||
TypeWithConversion(functionTypeForSam, argumentType)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirValueParameter.toFunctionTypeForSamOrNull(call: Candidate): ConeKotlinType? {
|
||||
val functionTypesOfSamConversions = call.functionTypesOfSamConversions ?: return null
|
||||
return call.argumentMapping?.entries?.firstNotNullOfOrNull {
|
||||
runIf(it.value == this) { functionTypesOfSamConversions[it.key.unwrapArgument()] }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// FIR_IDENTICAL
|
||||
fun interface Runnable {
|
||||
fun run()
|
||||
}
|
||||
|
||||
fun foo(r: Runnable, f: Runnable) = 1
|
||||
fun foo(r: Runnable, f: () -> Unit) = ""
|
||||
|
||||
fun test(): String {
|
||||
return foo(Runnable {}, {})
|
||||
}
|
||||
Generated
+6
@@ -32470,6 +32470,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt60983.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleSamConversionConflictResolution.kt")
|
||||
public void testMultipleSamConversionConflictResolution() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/multipleSamConversionConflictResolution.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OverloadPriority.kt")
|
||||
public void testOverloadPriority() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user