[FIR] Implement Int -> Long conversions for literals and operators over them
^KT-38895 ^KT-50996 Fixed ^KT-51000 Fixed ^KT-51003 Fixed ^KT-51018 Fixed
This commit is contained in:
committed by
teamcity
parent
cc86ca2a0f
commit
52b72a7dac
+2
-2
@@ -12,7 +12,7 @@ internal object PublicApproximatorConfiguration : TypeApproximatorConfiguration.
|
||||
override val allFlexible: Boolean get() = false
|
||||
override val errorType: Boolean get() = true
|
||||
override val definitelyNotNullType: Boolean get() = false
|
||||
override val integerLiteralType: Boolean get() = true
|
||||
override val integerLiteralConstantType: Boolean get() = true
|
||||
override val intersectionTypesInContravariantPositions: Boolean get() = true
|
||||
override val localTypes: Boolean get() = true
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -13,10 +13,12 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirModuleResolveSta
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty
|
||||
import org.jetbrains.kotlin.fir.originalIfFakeOverride
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.importedFromObjectData
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.originalForWrappedIntegerOperator
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
|
||||
internal interface KtFirSymbol<out S : FirBasedSymbol<*>> : KtSymbol, ValidityTokenOwner {
|
||||
@@ -64,6 +66,12 @@ internal tailrec fun FirDeclaration.ktSymbolOrigin(): KtSymbolOrigin = when (ori
|
||||
|
||||
importedFromObjectData.original.ktSymbolOrigin()
|
||||
}
|
||||
FirDeclarationOrigin.WrappedIntegerOperator -> {
|
||||
val original = (this as FirSimpleFunction).originalForWrappedIntegerOperator?.fir
|
||||
?: error("Declaration has WrappedIntegerOperator origin, but no originalForWrappedIntegerOperator present")
|
||||
|
||||
original.ktSymbolOrigin()
|
||||
}
|
||||
else -> {
|
||||
val overridden = (this as? FirCallableDeclaration)?.originalIfFakeOverride()
|
||||
?: throw InvalidFirDeclarationOriginForSymbol(this)
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ internal object PublicTypeApproximator {
|
||||
override val allFlexible: Boolean get() = false
|
||||
override val errorType: Boolean get() = true
|
||||
override val definitelyNotNullType: Boolean get() = false
|
||||
override val integerLiteralType: Boolean get() = true
|
||||
override val integerLiteralConstantType: Boolean get() = true
|
||||
override val intersectionTypesInContravariantPositions: Boolean get() = true
|
||||
override val anonymous: Boolean get() = true
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
KT element: KtBinaryExpression
|
||||
FIR element: FirFunctionCallImpl
|
||||
FIR element: FirIntegerLiteralOperatorCallImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
KT element: KtParenthesizedExpression
|
||||
FIR element: FirFunctionCallImpl
|
||||
FIR element: FirIntegerLiteralOperatorCallImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
|
||||
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
KT element: KtBlockStringTemplateEntry
|
||||
FIR element: FirFunctionCallImpl
|
||||
FIR element: FirIntegerLiteralOperatorCallImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
Int(1).R|kotlin/Int.plus|(Int(2))
|
||||
Int(1).R|kotlin/Int.plus|(Int(2))
|
||||
|
||||
+22
@@ -17477,6 +17477,28 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/integerLiterals")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class IntegerLiterals {
|
||||
@Test
|
||||
public void testAllFilesPresentInIntegerLiterals() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/integerLiterals"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intToLongConversion.kt")
|
||||
public void testIntToLongConversion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/integerLiterals/intToLongConversion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("literalsInInference.kt")
|
||||
public void testLiteralsInInference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/integerLiterals/literalsInInference.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/j+k")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
Reference in New Issue
Block a user