[FIR] Expand typealias for correct approximation of types (particularly Int and Long)
This commit is contained in:
+6
@@ -30669,6 +30669,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intToLongApproximationThroughTypeAlias.kt")
|
||||
public void testIntToLongApproximationThroughTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/intToLongApproximationThroughTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("isAsWithTypeAlias.kt")
|
||||
public void testIsAsWithTypeAlias() throws Exception {
|
||||
|
||||
+6
@@ -30669,6 +30669,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intToLongApproximationThroughTypeAlias.kt")
|
||||
public void testIntToLongApproximationThroughTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/intToLongApproximationThroughTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("isAsWithTypeAlias.kt")
|
||||
public void testIsAsWithTypeAlias() throws Exception {
|
||||
|
||||
+2
-1
@@ -877,7 +877,8 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
val integerLiteralType =
|
||||
ConeIntegerLiteralTypeImpl(constExpression.value as Long, isUnsigned = kind == ConstantValueKind.UnsignedIntegerLiteral)
|
||||
if (data.expectedType != null) {
|
||||
val approximatedType = integerLiteralType.getApproximatedType(data.expectedType?.coneTypeSafe())
|
||||
val coneType = data.expectedType?.coneTypeSafe<ConeKotlinType>()?.fullyExpandedType(session)
|
||||
val approximatedType = integerLiteralType.getApproximatedType(coneType)
|
||||
val newConstKind = approximatedType.toConstKind()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
constExpression.replaceKind(newConstKind as ConstantValueKind<T>)
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// FIR_IDENTICAL
|
||||
typealias Hash = Long
|
||||
|
||||
fun foo(): Hash {
|
||||
return 0
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun foo(): Hash /* = kotlin.Long */
|
||||
public typealias Hash = kotlin.Long
|
||||
Generated
+6
@@ -30765,6 +30765,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intToLongApproximationThroughTypeAlias.kt")
|
||||
public void testIntToLongApproximationThroughTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/intToLongApproximationThroughTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("isAsWithTypeAlias.kt")
|
||||
public void testIsAsWithTypeAlias() throws Exception {
|
||||
|
||||
+6
@@ -30669,6 +30669,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intToLongApproximationThroughTypeAlias.kt")
|
||||
public void testIntToLongApproximationThroughTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/intToLongApproximationThroughTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("isAsWithTypeAlias.kt")
|
||||
public void testIsAsWithTypeAlias() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user