[FIR] Expand typealiases in OverloadConflictResolver

^KT-52825 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-06-20 17:18:47 +03:00
committed by teamcity
parent b73783b693
commit eb453dc96b
7 changed files with 47 additions and 4 deletions
@@ -18149,6 +18149,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
public void testLiteralsInInference() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/literalsInInference.kt");
}
@Test
@TestMetadata("typealiasOnLong.kt")
public void testTypealiasOnLong() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt");
}
}
@Nested
@@ -18149,6 +18149,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
public void testLiteralsInInference() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/literalsInInference.kt");
}
@Test
@TestMetadata("typealiasOnLong.kt")
public void testTypealiasOnLong() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt");
}
}
@Nested
@@ -18149,6 +18149,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
public void testLiteralsInInference() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/literalsInInference.kt");
}
@Test
@TestMetadata("typealiasOnLong.kt")
public void testTypealiasOnLong() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt");
}
}
@Nested
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
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.*
import org.jetbrains.kotlin.name.StandardClassIds
@@ -173,18 +174,19 @@ abstract class AbstractConeCallConflictResolver(
called: FirCallableDeclaration
): List<TypeWithConversion> {
return buildList {
addIfNotNull(called.receiverTypeRef?.coneType?.let { TypeWithConversion(it) })
val session = inferenceComponents.session
addIfNotNull(called.receiverTypeRef?.coneType?.fullyExpandedType(session)?.let { TypeWithConversion(it) })
val typeForCallableReference = call.resultingTypeForCallableReference
if (typeForCallableReference != null) {
// Return type isn't needed here v
typeForCallableReference.typeArguments.dropLast(1)
.mapTo(this) {
TypeWithConversion((it as ConeKotlinType).removeTypeVariableTypes(inferenceComponents.session.typeContext))
TypeWithConversion((it as ConeKotlinType).fullyExpandedType(session).removeTypeVariableTypes(session.typeContext))
}
} else {
called.contextReceivers.mapTo(this) { TypeWithConversion(it.typeRef.coneType) }
called.contextReceivers.mapTo(this) { TypeWithConversion(it.typeRef.coneType.fullyExpandedType(session)) }
call.argumentMapping?.mapTo(this) { (_, parameter) ->
val argumentType = parameter.argumentType()
val argumentType = parameter.argumentType().fullyExpandedType(session)
if (!call.usesSAM) {
TypeWithConversion(argumentType)
} else {
@@ -0,0 +1,11 @@
// FIR_IDENTICAL
// ISSUE: KT-52825
typealias LLL = Long
fun foo(a: Int, b: Int) {}
fun foo(a: LLL, b: LLL) {}
fun test() {
foo(0, 0)
}
@@ -0,0 +1,6 @@
package
public fun foo(/*0*/ a: LLL /* = kotlin.Long */, /*1*/ b: LLL /* = kotlin.Long */): kotlin.Unit
public fun foo(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Unit
public fun test(): kotlin.Unit
public typealias LLL = kotlin.Long
@@ -18155,6 +18155,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
public void testLiteralsInInference() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/literalsInInference.kt");
}
@Test
@TestMetadata("typealiasOnLong.kt")
public void testTypealiasOnLong() throws Exception {
runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt");
}
}
@Nested