[FE] Drop ApproximateIntegerLiteralTypesInReceiverPosition language feature
This feature is not needed because it is unconditionally disabled for K1 (because of not fully correct implementation) and unconditionally enabled in K2 (K2 does not support old behavior) ^KT-38895
This commit is contained in:
committed by
Space Team
parent
26ff806440
commit
3cffb33ab7
+3
-15
@@ -22285,15 +22285,9 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_disabled.kt")
|
||||
public void testKt48361_disabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_disabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_enabled.kt")
|
||||
public void testKt48361_enabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_enabled.kt");
|
||||
@TestMetadata("kt48361.kt")
|
||||
public void testKt48361() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -22302,12 +22296,6 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/literalReceiverWithIntegerValueType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_newResolve.kt")
|
||||
public void testNewLiteralOperatorsResolution_newResolve() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/newLiteralOperatorsResolution_newResolve.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_warning.kt")
|
||||
public void testNewLiteralOperatorsResolution_warning() throws Exception {
|
||||
|
||||
+3
-15
@@ -22291,15 +22291,9 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_disabled.kt")
|
||||
public void testKt48361_disabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_disabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_enabled.kt")
|
||||
public void testKt48361_enabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_enabled.kt");
|
||||
@TestMetadata("kt48361.kt")
|
||||
public void testKt48361() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -22308,12 +22302,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/literalReceiverWithIntegerValueType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_newResolve.kt")
|
||||
public void testNewLiteralOperatorsResolution_newResolve() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/newLiteralOperatorsResolution_newResolve.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_warning.kt")
|
||||
public void testNewLiteralOperatorsResolution_warning() throws Exception {
|
||||
|
||||
+3
-15
@@ -22285,15 +22285,9 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_disabled.kt")
|
||||
public void testKt48361_disabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_disabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_enabled.kt")
|
||||
public void testKt48361_enabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_enabled.kt");
|
||||
@TestMetadata("kt48361.kt")
|
||||
public void testKt48361() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -22302,12 +22296,6 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/literalReceiverWithIntegerValueType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_newResolve.kt")
|
||||
public void testNewLiteralOperatorsResolution_newResolve() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/newLiteralOperatorsResolution_newResolve.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_warning.kt")
|
||||
public void testNewLiteralOperatorsResolution_warning() throws Exception {
|
||||
|
||||
-1
@@ -131,7 +131,6 @@ class VariableTypeAndInitializerResolver(
|
||||
NewSchemeOfIntegerOperatorResolutionChecker.checkArgument(
|
||||
variableType,
|
||||
initializer,
|
||||
languageVersionSettings,
|
||||
trace,
|
||||
constantExpressionEvaluator.module
|
||||
)
|
||||
|
||||
-6
@@ -6,11 +6,8 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -33,7 +30,6 @@ import org.jetbrains.kotlin.types.typeUtil.*
|
||||
|
||||
object NewSchemeOfIntegerOperatorResolutionChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.ApproximateIntegerLiteralTypesInReceiverPosition)) return
|
||||
for ((valueParameter, arguments) in resolvedCall.valueArguments) {
|
||||
val expectedType = if (valueParameter.isVararg) {
|
||||
valueParameter.varargElementType ?: continue
|
||||
@@ -54,11 +50,9 @@ object NewSchemeOfIntegerOperatorResolutionChecker : CallChecker {
|
||||
fun checkArgument(
|
||||
expectedType: KotlinType,
|
||||
argument: KtExpression,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
trace: BindingTrace,
|
||||
moduleDescriptor: ModuleDescriptor
|
||||
) {
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ApproximateIntegerLiteralTypesInReceiverPosition)) return
|
||||
val type = expectedType.lowerIfFlexible()
|
||||
if (type.isPrimitiveNumberOrNullableType()) {
|
||||
checkArgumentImpl(type, KtPsiUtil.deparenthesize(argument)!!, trace, moduleDescriptor)
|
||||
|
||||
+16
-41
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageFeature.ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
|
||||
@@ -286,10 +285,9 @@ class ConstantExpressionEvaluator(
|
||||
fun evaluateExpression(
|
||||
expression: KtExpression,
|
||||
trace: BindingTrace,
|
||||
expectedType: KotlinType? = TypeUtils.NO_EXPECTED_TYPE,
|
||||
isIndependentContext: Boolean = false
|
||||
expectedType: KotlinType? = TypeUtils.NO_EXPECTED_TYPE
|
||||
): CompileTimeConstant<*>? {
|
||||
val visitor = ConstantExpressionEvaluatorVisitor(this, trace, isIndependentContext)
|
||||
val visitor = ConstantExpressionEvaluatorVisitor(this, trace)
|
||||
val constant = visitor.evaluate(expression, expectedType) ?: return null
|
||||
|
||||
checkExperimentalityOfConstantLiteral(expression, constant, expectedType, trace)
|
||||
@@ -389,13 +387,10 @@ private val DIVISION_OPERATION_NAMES =
|
||||
|
||||
private class ConstantExpressionEvaluatorVisitor(
|
||||
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
|
||||
private val trace: BindingTrace,
|
||||
private val isIndependentContext: Boolean
|
||||
private val trace: BindingTrace
|
||||
) : KtVisitor<CompileTimeConstant<*>?, KotlinType>() {
|
||||
private val languageVersionSettings = constantExpressionEvaluator.languageVersionSettings
|
||||
private val builtIns = constantExpressionEvaluator.module.builtIns
|
||||
private val defaultValueForDontCreateIntegerLiteralType =
|
||||
languageVersionSettings.supportsFeature(ApproximateIntegerLiteralTypesInReceiverPosition)
|
||||
private val inlineConstTracker =
|
||||
if (constantExpressionEvaluator.inlineConstTracker is InlineConstTracker.DoNothing)
|
||||
null
|
||||
@@ -530,8 +525,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
isUnsignedLongNumberLiteral = isUnsignedLong,
|
||||
usesVariableAsConstant = false,
|
||||
usesNonConstValAsConstant = false,
|
||||
isConvertableConstVal = false,
|
||||
dontCreateILT = defaultValueForDontCreateIntegerLiteralType && isIndependentContext
|
||||
isConvertableConstVal = false
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -581,8 +575,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
canBeUsedInAnnotation = canBeUsedInAnnotation,
|
||||
usesVariableAsConstant = usesVariableAsConstant,
|
||||
usesNonConstValAsConstant = usesNonConstantVariableAsConstant,
|
||||
isConvertableConstVal = false,
|
||||
dontCreateILT = false
|
||||
isConvertableConstVal = false
|
||||
)
|
||||
)
|
||||
else null
|
||||
@@ -646,8 +639,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
isUnsignedLongNumberLiteral = false,
|
||||
usesVariableAsConstant = leftConstant.usesVariableAsConstant || rightConstant.usesVariableAsConstant,
|
||||
usesNonConstValAsConstant = leftConstant.usesNonConstValAsConstant || rightConstant.usesNonConstValAsConstant,
|
||||
isConvertableConstVal = false,
|
||||
dontCreateILT = false
|
||||
isConvertableConstVal = false
|
||||
)
|
||||
)
|
||||
} else {
|
||||
@@ -666,8 +658,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
private fun evaluateCall(
|
||||
callExpression: KtExpression,
|
||||
receiverExpression: KtExpression,
|
||||
expectedType: KotlinType?,
|
||||
isUnaryPlusMinus: Boolean = false
|
||||
expectedType: KotlinType?
|
||||
): CompileTimeConstant<*>? {
|
||||
val resolvedCall = callExpression.getResolvedCall(trace.bindingContext) ?: return null
|
||||
if (!KotlinBuiltIns.isUnderKotlinPackage(resolvedCall.resultingDescriptor)) return null
|
||||
@@ -689,12 +680,9 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
val usesNonConstValAsConstant = usesNonConstValAsConstant(argumentForReceiver.expression)
|
||||
val isNumberConversionMethod = resultingDescriptorName in OperatorConventions.NUMBER_CONVERSIONS
|
||||
val isCharCode = argumentForReceiver.ctcType == CHAR && resultingDescriptorName == StandardNames.CHAR_CODE
|
||||
val dontCreateILT = defaultValueForDontCreateIntegerLiteralType &&
|
||||
!isUnaryPlusMinus &&
|
||||
!hasIntegerLiteralType(receiverExpression)
|
||||
return createConstant(
|
||||
result,
|
||||
expectedType.takeUnless { dontCreateILT },
|
||||
expectedType,
|
||||
CompileTimeConstant.Parameters(
|
||||
canBeUsedInAnnotation,
|
||||
!isNumberConversionMethod && !isCharCode && isArgumentPure,
|
||||
@@ -702,8 +690,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
isUnsignedLongNumberLiteral = false,
|
||||
usesVariableAsConstant,
|
||||
usesNonConstValAsConstant,
|
||||
isConvertableConstVal = false,
|
||||
dontCreateILT = dontCreateILT
|
||||
isConvertableConstVal = false
|
||||
)
|
||||
)
|
||||
} else if (argumentsEntrySet.size == 1) {
|
||||
@@ -738,7 +725,6 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
usesVariableAsConstant(argumentForReceiver.expression) || usesVariableAsConstant(argumentForParameter.expression)
|
||||
val usesNonConstValAsConstant =
|
||||
usesNonConstValAsConstant(argumentForReceiver.expression) || usesNonConstValAsConstant(argumentForParameter.expression)
|
||||
val dontCreateILT = defaultValueForDontCreateIntegerLiteralType && !hasIntegerLiteralType(receiverExpression)
|
||||
val parameters = CompileTimeConstant.Parameters(
|
||||
canBeUsedInAnnotation,
|
||||
areArgumentsPure,
|
||||
@@ -746,8 +732,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
isUnsignedLongNumberLiteral = false,
|
||||
usesVariableAsConstant,
|
||||
usesNonConstValAsConstant,
|
||||
isConvertableConstVal = false,
|
||||
dontCreateILT = dontCreateILT
|
||||
isConvertableConstVal = false
|
||||
)
|
||||
return when (resultingDescriptorName) {
|
||||
OperatorNameConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression)?.wrap(parameters)
|
||||
@@ -755,7 +740,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
else -> {
|
||||
createConstant(
|
||||
result,
|
||||
expectedType.takeUnless { dontCreateILT },
|
||||
expectedType,
|
||||
parameters
|
||||
)
|
||||
}
|
||||
@@ -777,9 +762,6 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
private fun isPureConstant(expression: KtExpression) =
|
||||
ConstantExpressionEvaluator.getConstant(expression, trace.bindingContext)?.isPure ?: false
|
||||
|
||||
private fun hasIntegerLiteralType(expression: KtExpression): Boolean =
|
||||
ConstantExpressionEvaluator.getConstant(expression, trace.bindingContext)?.hasIntegerLiteralType ?: false
|
||||
|
||||
private fun evaluateUnaryAndCheck(receiver: OperationArgument, name: String, callExpression: KtExpression): Any? {
|
||||
return evaluateUnaryAndCheck(name, receiver.ctcType, receiver.value) {
|
||||
trace.report(Errors.INTEGER_OVERFLOW.on(callExpression.getStrictParentOfType() ?: callExpression))
|
||||
@@ -803,12 +785,10 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
|
||||
override fun visitUnaryExpression(expression: KtUnaryExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val leftExpression = expression.baseExpression ?: return null
|
||||
val tokenType = expression.operationToken
|
||||
return evaluateCall(
|
||||
expression.operationReference,
|
||||
leftExpression,
|
||||
expectedType,
|
||||
isUnaryPlusMinus = tokenType == KtTokens.PLUS || tokenType == KtTokens.MINUS
|
||||
expectedType
|
||||
)
|
||||
}
|
||||
|
||||
@@ -847,8 +827,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
isUnsignedLongNumberLiteral = false,
|
||||
usesVariableAsConstant = true,
|
||||
usesNonConstValAsConstant = !callableDescriptor.isConst,
|
||||
isConvertableConstVal = isConvertableConstVal,
|
||||
dontCreateILT = true
|
||||
isConvertableConstVal = isConvertableConstVal
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -1108,9 +1087,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
}
|
||||
|
||||
if (TypeUtils.noExpectedType(expectedType) || expectedType.isError) {
|
||||
return if (parameters.dontCreateILT) {
|
||||
value.createSimpleIntCompileTimeConst(parameters)
|
||||
} else createIntegerValueTypeConstant(
|
||||
return createIntegerValueTypeConstant(
|
||||
value,
|
||||
constantExpressionEvaluator.module,
|
||||
parameters,
|
||||
@@ -1159,8 +1136,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
isUnsignedLong: Boolean = false,
|
||||
usesVariableAsConstant: Boolean = false,
|
||||
usesNonConstValAsConstant: Boolean = false,
|
||||
isConvertableConstVal: Boolean = false,
|
||||
dontCreateILT: Boolean = false
|
||||
isConvertableConstVal: Boolean = false
|
||||
): TypedCompileTimeConstant<T> =
|
||||
wrap(
|
||||
CompileTimeConstant.Parameters(
|
||||
@@ -1170,8 +1146,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
isUnsignedLong,
|
||||
usesVariableAsConstant,
|
||||
usesNonConstValAsConstant,
|
||||
isConvertableConstVal,
|
||||
dontCreateILT
|
||||
isConvertableConstVal
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+5
-9
@@ -181,7 +181,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
checkNull(expression, context, typeInfo.getType());
|
||||
|
||||
components.constantExpressionEvaluator.evaluateExpression(
|
||||
expression, context.trace, context.expectedType, evaluateIntegerConstantInIndependentMode(context)
|
||||
expression, context.trace, context.expectedType
|
||||
);
|
||||
return components.dataFlowAnalyzer.checkType(typeInfo, expression, context); // TODO : Extensions to this
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
CompileTimeConstant<?> compileTimeConstant = components.constantExpressionEvaluator.evaluateExpression(
|
||||
expression, context.trace, context.expectedType, evaluateIntegerConstantInIndependentMode(context)
|
||||
expression, context.trace, context.expectedType
|
||||
);
|
||||
|
||||
if (compileTimeConstant instanceof UnsignedErrorValueTypeConstant) {
|
||||
@@ -830,7 +830,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
CompileTimeConstant<?> value = components.constantExpressionEvaluator.evaluateExpression(
|
||||
expression, contextWithExpectedType.trace, contextWithExpectedType.expectedType, evaluateIntegerConstantInIndependentMode(context)
|
||||
expression, contextWithExpectedType.trace, contextWithExpectedType.expectedType
|
||||
);
|
||||
if (value != null) {
|
||||
return components.dataFlowAnalyzer.createCompileTimeConstantTypeInfo(value, expression, contextWithExpectedType);
|
||||
@@ -1126,7 +1126,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
result = TypeInfoFactoryKt.noTypeInfo(context);
|
||||
}
|
||||
CompileTimeConstant<?> value = components.constantExpressionEvaluator.evaluateExpression(
|
||||
expression, contextWithExpectedType.trace, contextWithExpectedType.expectedType, evaluateIntegerConstantInIndependentMode(context)
|
||||
expression, contextWithExpectedType.trace, contextWithExpectedType.expectedType
|
||||
);
|
||||
if (value != null) {
|
||||
return components.dataFlowAnalyzer.createCompileTimeConstantTypeInfo(value, expression, contextWithExpectedType);
|
||||
@@ -1602,7 +1602,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
for (KtStringTemplateEntry entry : expression.getEntries()) {
|
||||
entry.accept(visitor);
|
||||
}
|
||||
components.constantExpressionEvaluator.evaluateExpression(expression, context.trace, contextWithExpectedType.expectedType, evaluateIntegerConstantInIndependentMode(context));
|
||||
components.constantExpressionEvaluator.evaluateExpression(expression, context.trace, contextWithExpectedType.expectedType);
|
||||
return components.dataFlowAnalyzer.checkType(visitor.typeInfo.replaceType(components.builtIns.getStringType()),
|
||||
expression,
|
||||
contextWithExpectedType);
|
||||
@@ -1805,8 +1805,4 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
return BindingContextUtils.getRecordedTypeInfo(expression, context.trace.getBindingContext());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean evaluateIntegerConstantInIndependentMode(ExpressionTypingContext context) {
|
||||
return context.contextDependency == INDEPENDENT && context.languageVersionSettings.supportsFeature(LanguageFeature.ApproximateIntegerLiteralTypesInReceiverPosition);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -474,7 +474,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
DataFlowValue rightValue = components.dataFlowValueFactory.createDataFlowValue(right, rightType, context);
|
||||
// We cannot say here anything new about rightValue except it has the same value as leftValue
|
||||
resultInfo = resultInfo.replaceDataFlowInfo(dataFlowInfo.assign(leftValue, rightValue, components.languageVersionSettings));
|
||||
NewSchemeOfIntegerOperatorResolutionChecker.checkArgument(expectedType, right, context.languageVersionSettings, context.trace, components.moduleDescriptor);
|
||||
NewSchemeOfIntegerOperatorResolutionChecker.checkArgument(expectedType, right, context.trace, components.moduleDescriptor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -75,7 +75,6 @@ class ValueParameterResolver(
|
||||
NewSchemeOfIntegerOperatorResolutionChecker.checkArgument(
|
||||
type,
|
||||
defaultValue,
|
||||
context.languageVersionSettings,
|
||||
context.trace,
|
||||
constantExpressionEvaluator.module
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$TESTDATA_DIR$/overridingXx.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-XXLanguage\:+ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
-XXLanguage\:+RangeUntilOperator
|
||||
|
||||
@@ -1 +1 @@
|
||||
-XXLanguage:-ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
-XXLanguage:-RangeUntilOperator
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
fun foo(ttlMillis: Long = 5 * 60 * 1000) {}
|
||||
|
||||
const val cacheSize: Long = 4096 * 4
|
||||
fun test(): Int {
|
||||
var res = 0
|
||||
for (x in 100 ..< 1) {
|
||||
res += x
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
warning: ATTENTION!
|
||||
This build uses unsafe internal compiler arguments:
|
||||
|
||||
-XXLanguage:-ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
-XXLanguage:-RangeUntilOperator
|
||||
|
||||
This mode is not recommended for production use,
|
||||
as no stability/compatibility guarantees are given on
|
||||
compiler or generated code. Use it at your own risk!
|
||||
|
||||
compiler/testData/cli/jvm/readingConfigFromEnvironment/overridingXx.kt:1:9: warning: parameter 'ttlMillis' is never used
|
||||
fun foo(ttlMillis: Long = 5 * 60 * 1000) {}
|
||||
^
|
||||
OK
|
||||
compiler/testData/cli/jvm/readingConfigFromEnvironment/overridingXx.kt:3:19: error: this declaration needs opt-in. Its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
|
||||
for (x in 100 ..< 1) {
|
||||
^
|
||||
compiler/testData/cli/jvm/readingConfigFromEnvironment/overridingXx.kt:3:19: error: the feature "range until operator" is disabled
|
||||
for (x in 100 ..< 1) {
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// WITH_STDLIB
|
||||
// This test exists only to check that we don't accidentally break the buggy behavior of the old JVM backend in JVM IR (KT-42321).
|
||||
// Feel free to remove it as soon as there's no language version where such code is allowed (KT-38895).
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature; for reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
fun box(): String {
|
||||
val a1: Byte = 1.plus(1)
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature; for reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
fun box(): String {
|
||||
val a1: Byte? = 1.plus(1)
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature; for reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
fun box(): String {
|
||||
val a1: Byte = 1 + 1
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature; for reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
fun box(): String {
|
||||
val a1: Byte? = 1 + 1
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
|
||||
fun box(): String {
|
||||
val a: Long = 2147483647 + 1
|
||||
if (a != -2147483648L) return "fail: in this case we should add to ints and than cast the result to long - overflow expected"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_FIR_DIAGNOSTICS
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_FIR_DIAGNOSTICS
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_FIR_DIAGNOSTICS
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_FIR_DIAGNOSTICS
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature; for reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// SKIP_JDK6
|
||||
// FULL_JDK
|
||||
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature; for reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
fun box(): String {
|
||||
val a1: Byte = 1.unaryMinus()
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: don't support legacy feature; for reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
fun box(): String {
|
||||
val a1: Byte? = 1.unaryMinus()
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// WITH_REFLECT
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
@@ -65,4 +64,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// WITH_REFLECT
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
@@ -62,4 +61,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
// For reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
val a: Byte = 1 + 10
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
// For reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
val a: Short = 1 + 255
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(<!MISSING_VAL_ON_ANNOTATION_PARAMETER!>p1: Int<!>,
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(<!MISSING_VAL_ON_ANNOTATION_PARAMETER!>p1: Int<!>,
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
package test
|
||||
|
||||
annotation class Ann(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
|
||||
// SKIP_JAVAC
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
|
||||
// SKIP_JAVAC
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
fun fooInt(p: Int) = p
|
||||
fun fooLong(p: Long) = p
|
||||
fun fooByte(p: Byte) = p
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
val p1: Byte = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
|
||||
val p2: Short = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
|
||||
val p3: Int = (1 + 2) * 2
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
val p1: Byte = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
|
||||
val p2: Short = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
|
||||
val p1: Byte = <!INTEGER_OPERATOR_RESOLVE_WILL_CHANGE!>(1 + 2) * 2<!>
|
||||
val p2: Short = <!INTEGER_OPERATOR_RESOLVE_WILL_CHANGE!>(1 + 2) * 2<!>
|
||||
val p3: Int = (1 + 2) * 2
|
||||
val p4: Long = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
|
||||
val p4: Long = (1 + 2) * 2
|
||||
|
||||
val b1: Byte = <!TYPE_MISMATCH!>(1.toByte() + 2) * 2<!>
|
||||
val b2: Short = <!TYPE_MISMATCH!>(1.toShort() + 2) * 2<!>
|
||||
val b1: Byte = <!INTEGER_OPERATOR_RESOLVE_WILL_CHANGE, TYPE_MISMATCH!>(1.toByte() + 2) * 2<!>
|
||||
val b2: Short = <!INTEGER_OPERATOR_RESOLVE_WILL_CHANGE, TYPE_MISMATCH!>(1.toShort() + 2) * 2<!>
|
||||
val b3: Int = (1.toInt() + 2) * 2
|
||||
val b4: Long = (1.toLong() + 2) * 2
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ public val b3: kotlin.Int = 6
|
||||
public val b4: kotlin.Long = 6.toLong()
|
||||
public val i1: kotlin.Int = 6
|
||||
public val i2: kotlin.Int = 6
|
||||
public val p1: kotlin.Byte = 6
|
||||
public val p2: kotlin.Short = 6
|
||||
public val p1: kotlin.Byte = 6.toByte()
|
||||
public val p2: kotlin.Short = 6.toShort()
|
||||
public val p3: kotlin.Int = 6
|
||||
public val p4: kotlin.Long = 6
|
||||
public val p4: kotlin.Long = 6.toLong()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// ISSUE: KT-47447
|
||||
// FULL_JDK
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// ISSUE: Kt-47447, KT-47729
|
||||
|
||||
fun takeLong(value : Long) {}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// ISSUE: Kt-47447, KT-47729
|
||||
|
||||
fun takeLong(x: Long) {}
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
|
||||
fun foo(ttlMillis: Long = 5 * 60 * 1000) {}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
|
||||
fun foo(ttlMillis: Long = 5 * 60 * 1000) {}
|
||||
|
||||
const val cacheSize: Long = 4096 * 4
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
|
||||
fun foo(ttlMillis: Long = <!TYPE_MISMATCH!>5 * 60 * 1000<!>) {}
|
||||
|
||||
const val cacheSize: Long = <!TYPE_MISMATCH!>4096 * 4<!>
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package
|
||||
|
||||
public const val cacheSize: kotlin.Long = 16384
|
||||
public fun foo(/*0*/ ttlMillis: kotlin.Long = ...): kotlin.Unit
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// This test exists only to check that we don't accidentally break the buggy behavior of the old JVM backend in JVM IR (KT-42321).
|
||||
// Feel free to remove it as soon as there's no language version where such code is allowed (KT-38895).
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// This test exists only to check that we don't accidentally break the buggy behavior of the old JVM backend in JVM IR (KT-42321).
|
||||
// Feel free to remove it as soon as there's no language version where such code is allowed (KT-38895).
|
||||
|
||||
|
||||
Vendored
-116
@@ -1,116 +0,0 @@
|
||||
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-38895
|
||||
|
||||
fun takeByte(b: Byte) {}
|
||||
fun takeInt(b: Int) {}
|
||||
fun takeLong(b: Long) {}
|
||||
|
||||
fun testByteBinaryOperators() {
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 + 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 - 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 * 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 / 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 % 1<!>)
|
||||
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.plus(1)<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.minus(1)<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.times(1)<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.div(1)<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.rem(1)<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 shl 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 shr 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 ushr 1<!>)
|
||||
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 and 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 or 1<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2 xor 1<!>)
|
||||
}
|
||||
|
||||
fun testByteUnaryOperators() {
|
||||
// No mismatch
|
||||
takeByte(+1)
|
||||
takeByte(-1)
|
||||
|
||||
// Mismatch
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.unaryPlus()<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.unaryMinus()<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>2.inv()<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1.inc()<!>)
|
||||
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1.dec()<!>)
|
||||
}
|
||||
|
||||
fun testLongBinaryOperators() {
|
||||
takeLong(2 + 1)
|
||||
takeLong(2 - 1)
|
||||
takeLong(2 * 1)
|
||||
takeLong(2 / 1)
|
||||
takeLong(2 % 1)
|
||||
|
||||
takeLong(2.plus(1))
|
||||
takeLong(2.minus(1))
|
||||
takeLong(2.times(1))
|
||||
takeLong(2.div(1))
|
||||
takeLong(2.rem(1))
|
||||
takeLong(2 shl 1)
|
||||
takeLong(2 shr 1)
|
||||
takeLong(2 ushr 1)
|
||||
|
||||
takeLong(2 and 1)
|
||||
takeLong(2 or 1)
|
||||
takeLong(2 xor 1)
|
||||
|
||||
// positive
|
||||
takeLong(2 * 100000000000)
|
||||
}
|
||||
|
||||
fun testLongUnaryOperators() {
|
||||
// No mismatch
|
||||
takeLong(+1)
|
||||
takeLong(-1)
|
||||
|
||||
// Mismatch
|
||||
takeLong(2.unaryPlus())
|
||||
takeLong(2.unaryMinus())
|
||||
takeLong(2.inv())
|
||||
takeLong(<!ARGUMENT_TYPE_MISMATCH!>1.inc()<!>)
|
||||
takeLong(<!ARGUMENT_TYPE_MISMATCH!>1.dec()<!>)
|
||||
}
|
||||
|
||||
fun testIntBinaryOperators() {
|
||||
takeInt(2 + 1)
|
||||
takeInt(2 - 1)
|
||||
takeInt(2 * 1)
|
||||
takeInt(2 / 1)
|
||||
takeInt(2 % 1)
|
||||
|
||||
takeInt(2.plus(1))
|
||||
takeInt(2.minus(1))
|
||||
takeInt(2.times(1))
|
||||
takeInt(2.div(1))
|
||||
takeInt(2.rem(1))
|
||||
takeInt(2 shl 1)
|
||||
takeInt(2 shr 1)
|
||||
takeInt(2 ushr 1)
|
||||
|
||||
takeInt(2 and 1)
|
||||
takeInt(2 or 1)
|
||||
takeInt(2 xor 1)
|
||||
}
|
||||
|
||||
fun testIntUnaryOperators() {
|
||||
takeInt(+1)
|
||||
takeInt(-1)
|
||||
|
||||
takeInt(2.unaryPlus())
|
||||
takeInt(2.unaryMinus())
|
||||
takeInt(2.inv())
|
||||
takeInt(1.inc())
|
||||
takeInt(1.dec())
|
||||
}
|
||||
|
||||
fun testNoOperators() {
|
||||
takeByte(1)
|
||||
takeInt(1)
|
||||
takeLong(1)
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-38895
|
||||
|
||||
fun takeByte(b: Byte) {}
|
||||
fun takeInt(b: Int) {}
|
||||
fun takeLong(b: Long) {}
|
||||
|
||||
fun testByteBinaryOperators() {
|
||||
takeByte(<!TYPE_MISMATCH!>2 + 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 - 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 * 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 / 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 % 1<!>)
|
||||
|
||||
takeByte(<!TYPE_MISMATCH!>2.plus(1)<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2.minus(1)<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2.times(1)<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2.div(1)<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2.rem(1)<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 shl 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 shr 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 ushr 1<!>)
|
||||
|
||||
takeByte(<!TYPE_MISMATCH!>2 and 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 or 1<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2 xor 1<!>)
|
||||
}
|
||||
|
||||
fun testByteUnaryOperators() {
|
||||
// No mismatch
|
||||
takeByte(+1)
|
||||
takeByte(-1)
|
||||
|
||||
// Mismatch
|
||||
takeByte(<!TYPE_MISMATCH!>2.unaryPlus()<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2.unaryMinus()<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>2.inv()<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>1.inc()<!>)
|
||||
takeByte(<!TYPE_MISMATCH!>1.dec()<!>)
|
||||
}
|
||||
|
||||
fun testLongBinaryOperators() {
|
||||
takeLong(<!TYPE_MISMATCH!>2 + 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 - 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 * 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 / 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 % 1<!>)
|
||||
|
||||
takeLong(<!TYPE_MISMATCH!>2.plus(1)<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2.minus(1)<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2.times(1)<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2.div(1)<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2.rem(1)<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 shl 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 shr 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 ushr 1<!>)
|
||||
|
||||
takeLong(<!TYPE_MISMATCH!>2 and 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 or 1<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2 xor 1<!>)
|
||||
|
||||
// positive
|
||||
takeLong(2 * 100000000000)
|
||||
}
|
||||
|
||||
fun testLongUnaryOperators() {
|
||||
// No mismatch
|
||||
takeLong(+1)
|
||||
takeLong(-1)
|
||||
|
||||
// Mismatch
|
||||
takeLong(<!TYPE_MISMATCH!>2.unaryPlus()<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2.unaryMinus()<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>2.inv()<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>1.inc()<!>)
|
||||
takeLong(<!TYPE_MISMATCH!>1.dec()<!>)
|
||||
}
|
||||
|
||||
fun testIntBinaryOperators() {
|
||||
takeInt(2 + 1)
|
||||
takeInt(2 - 1)
|
||||
takeInt(2 * 1)
|
||||
takeInt(2 / 1)
|
||||
takeInt(2 % 1)
|
||||
|
||||
takeInt(2.plus(1))
|
||||
takeInt(2.minus(1))
|
||||
takeInt(2.times(1))
|
||||
takeInt(2.div(1))
|
||||
takeInt(2.rem(1))
|
||||
takeInt(2 shl 1)
|
||||
takeInt(2 shr 1)
|
||||
takeInt(2 ushr 1)
|
||||
|
||||
takeInt(2 and 1)
|
||||
takeInt(2 or 1)
|
||||
takeInt(2 xor 1)
|
||||
}
|
||||
|
||||
fun testIntUnaryOperators() {
|
||||
takeInt(+1)
|
||||
takeInt(-1)
|
||||
|
||||
takeInt(2.unaryPlus())
|
||||
takeInt(2.unaryMinus())
|
||||
takeInt(2.inv())
|
||||
takeInt(1.inc())
|
||||
takeInt(1.dec())
|
||||
}
|
||||
|
||||
fun testNoOperators() {
|
||||
takeByte(1)
|
||||
takeInt(1)
|
||||
takeLong(1)
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package
|
||||
|
||||
public fun takeByte(/*0*/ b: kotlin.Byte): kotlin.Unit
|
||||
public fun takeInt(/*0*/ b: kotlin.Int): kotlin.Unit
|
||||
public fun takeLong(/*0*/ b: kotlin.Long): kotlin.Unit
|
||||
public fun testByteBinaryOperators(): kotlin.Unit
|
||||
public fun testByteUnaryOperators(): kotlin.Unit
|
||||
public fun testIntBinaryOperators(): kotlin.Unit
|
||||
public fun testIntUnaryOperators(): kotlin.Unit
|
||||
public fun testLongBinaryOperators(): kotlin.Unit
|
||||
public fun testLongUnaryOperators(): kotlin.Unit
|
||||
public fun testNoOperators(): kotlin.Unit
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-38895
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-38895
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
// SKIP_KT_DUMP
|
||||
// This test exists only to check that we don't accidentally break the buggy behavior of the old JVM backend in JVM IR (KT-42321).
|
||||
// Feel free to remove it as soon as there's no language version where such code is allowed (KT-38895).
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// IGNORE_BACKEND_K2: ANY
|
||||
// For reasons this test is ignored, go to KT-46419
|
||||
// FIR status: KT-46419, ILT conversions to Byte and Short are not supported by design
|
||||
|
||||
val test1: Long = 42
|
||||
val test2: Short = 42
|
||||
|
||||
Generated
+3
-15
@@ -22291,15 +22291,9 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_disabled.kt")
|
||||
public void testKt48361_disabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_disabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48361_enabled.kt")
|
||||
public void testKt48361_enabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361_enabled.kt");
|
||||
@TestMetadata("kt48361.kt")
|
||||
public void testKt48361() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/kt48361.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -22308,12 +22302,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/literalReceiverWithIntegerValueType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_newResolve.kt")
|
||||
public void testNewLiteralOperatorsResolution_newResolve() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/numbers/newLiteralOperatorsResolution_newResolve.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("newLiteralOperatorsResolution_warning.kt")
|
||||
public void testNewLiteralOperatorsResolution_warning() throws Exception {
|
||||
|
||||
-6
@@ -128,12 +128,6 @@ abstract class AbstractDiagnosticTest : AbstractKotlinCompilerTest() {
|
||||
}
|
||||
|
||||
// ----------------------- constant evaluation tests -----------------------
|
||||
forTestsMatching("compiler/testData/diagnostics/tests/constantEvaluator/*") {
|
||||
defaultDirectives {
|
||||
LANGUAGE with "-ApproximateIntegerLiteralTypesInReceiverPosition"
|
||||
}
|
||||
}
|
||||
|
||||
forTestsMatching("compiler/testData/diagnostics/tests/constantEvaluator/constant/*") {
|
||||
defaultDirectives {
|
||||
CHECK_COMPILE_TIME_VALUES with ConstantValuesHandler.Mode.Constant
|
||||
|
||||
@@ -287,9 +287,6 @@ enum class LanguageFeature(
|
||||
// Disabled for indefinite time. See KT-53751
|
||||
IgnoreNullabilityForErasedValueParameters(sinceVersion = null, kind = BUG_FIX),
|
||||
|
||||
// Disabled for indefinite time. See KT-48535 and related discussion
|
||||
ApproximateIntegerLiteralTypesInReceiverPosition(sinceVersion = null),
|
||||
|
||||
// Disabled for indefinite time. Disables restrictions of builder inference without annotation
|
||||
// Note: In 1.7.0, builder inference without annotation was introduced.
|
||||
// However, later we encountered various situations when it works incorrectly, and decided to forbid them.
|
||||
|
||||
@@ -28,7 +28,7 @@ interface CompileTimeConstant<out T> {
|
||||
val isError: Boolean
|
||||
get() = false
|
||||
|
||||
val parameters: CompileTimeConstant.Parameters
|
||||
val parameters: Parameters
|
||||
|
||||
val moduleDescriptor: ModuleDescriptor
|
||||
|
||||
@@ -58,8 +58,7 @@ interface CompileTimeConstant<out T> {
|
||||
val usesVariableAsConstant: Boolean,
|
||||
val usesNonConstValAsConstant: Boolean,
|
||||
// `isConvertableConstVal` means that this is `const val` that has `ImplicitIntegerCoercion` annotation
|
||||
val isConvertableConstVal: Boolean,
|
||||
val dontCreateILT: Boolean
|
||||
val isConvertableConstVal: Boolean
|
||||
)
|
||||
|
||||
override fun equals(other: Any?): Boolean
|
||||
@@ -150,8 +149,7 @@ class IntegerValueTypeConstant(
|
||||
isUnsignedLongNumberLiteral = parameters.isUnsignedLongNumberLiteral,
|
||||
usesVariableAsConstant = parameters.usesVariableAsConstant,
|
||||
usesNonConstValAsConstant = parameters.usesNonConstValAsConstant,
|
||||
isConvertableConstVal = parameters.isConvertableConstVal,
|
||||
dontCreateILT = false
|
||||
isConvertableConstVal = parameters.isConvertableConstVal
|
||||
)
|
||||
|
||||
return IntegerValueTypeConstant(value, module, newParameters, newInferenceEnabled, convertedFromSigned = true)
|
||||
@@ -165,8 +163,7 @@ class IntegerValueTypeConstant(
|
||||
isUnsignedLongNumberLiteral = parameters.isUnsignedLongNumberLiteral,
|
||||
usesVariableAsConstant = parameters.usesVariableAsConstant,
|
||||
usesNonConstValAsConstant = parameters.usesNonConstValAsConstant,
|
||||
isConvertableConstVal = parameters.isConvertableConstVal,
|
||||
dontCreateILT = false
|
||||
isConvertableConstVal = parameters.isConvertableConstVal
|
||||
)
|
||||
|
||||
return IntegerValueTypeConstant(value, module, newParameters, newInferenceEnabled, convertedFromSigned = true)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
||||
// EXPECTED_REACHABLE_NODES: 1375
|
||||
package foo
|
||||
|
||||
@@ -14,4 +13,4 @@ fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun id(x: Long) = x
|
||||
fun id(x: Long) = x
|
||||
|
||||
Reference in New Issue
Block a user