[FIR] Expand expected types before ILT approximation
^KT-56176 Fixed
This commit is contained in:
committed by
Space Team
parent
4941fcd10e
commit
a084bcbbb5
Generated
+6
@@ -2648,6 +2648,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("integerLiteralWithExpectedTypealiasType.kt")
|
||||
public void testIntegerLiteralWithExpectedTypealiasType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/integerLiteralWithExpectedTypealiasType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("internalPotentialFakeOverride.kt")
|
||||
public void testInternalPotentialFakeOverride() throws Exception {
|
||||
|
||||
+6
@@ -2648,6 +2648,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex
|
||||
runTest("compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("integerLiteralWithExpectedTypealiasType.kt")
|
||||
public void testIntegerLiteralWithExpectedTypealiasType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/integerLiteralWithExpectedTypealiasType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("internalPotentialFakeOverride.kt")
|
||||
public void testInternalPotentialFakeOverride() throws Exception {
|
||||
|
||||
+1
-1
@@ -695,7 +695,7 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
val finalType = finalSubstitutor.substituteOrNull(initialType)
|
||||
var resultType = block.resultType.withReplacedConeType(finalType)
|
||||
resultType.coneTypeSafe<ConeIntegerLiteralType>()?.let {
|
||||
resultType = resultType.resolvedTypeFromPrototype(it.getApproximatedType(data?.getExpectedType(block)))
|
||||
resultType = resultType.resolvedTypeFromPrototype(it.getApproximatedType(data?.getExpectedType(block)?.fullyExpandedType(session)))
|
||||
}
|
||||
block.replaceTypeRef(resultType)
|
||||
session.lookupTracker?.recordTypeResolveAsLookup(resultType, block.source, context.file.source)
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildResolvedErrorReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.scope
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
|
||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||
@@ -64,7 +65,7 @@ class IntegerLiteralAndOperatorApproximationTransformer(
|
||||
data: ConeKotlinType?
|
||||
): FirStatement {
|
||||
val type = constExpression.resultType.coneTypeSafe<ConeIntegerLiteralType>() ?: return constExpression
|
||||
val approximatedType = type.getApproximatedType(data)
|
||||
val approximatedType = type.getApproximatedType(data?.fullyExpandedType(session))
|
||||
constExpression.resultType = constExpression.resultType.resolvedTypeFromPrototype(approximatedType)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val kind = approximatedType.toConstKind() as ConstantValueKind<T>
|
||||
@@ -79,7 +80,7 @@ class IntegerLiteralAndOperatorApproximationTransformer(
|
||||
@Suppress("UnnecessaryVariable")
|
||||
val call = integerLiteralOperatorCall
|
||||
val operatorType = call.resultType.coneTypeSafe<ConeIntegerLiteralType>() ?: return call
|
||||
val approximatedType = operatorType.getApproximatedType(data)
|
||||
val approximatedType = operatorType.getApproximatedType(data?.fullyExpandedType(session))
|
||||
call.transformDispatchReceiver(this, null)
|
||||
call.transformExtensionReceiver(this, null)
|
||||
call.argumentList.transformArguments(this, null)
|
||||
|
||||
Reference in New Issue
Block a user