[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:
Dmitriy Novozhilov
2022-11-30 12:22:09 +02:00
committed by Space Team
parent 26ff806440
commit 3cffb33ab7
90 changed files with 90 additions and 494 deletions
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(<!MISSING_VAL_ON_ANNOTATION_PARAMETER!>p1: Int<!>,
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(<!MISSING_VAL_ON_ANNOTATION_PARAMETER!>p1: Int<!>,
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -1,4 +1,3 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
package test
annotation class Ann(
@@ -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
@@ -1,4 +1,4 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses -ApproximateIntegerLiteralTypesInReceiverPosition
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
// SKIP_JAVAC
// ALLOW_KOTLIN_PACKAGE
@@ -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,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,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,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,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,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,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,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)
}
@@ -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)
}
@@ -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,4 +1,3 @@
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
// WITH_STDLIB
// ISSUE: KT-38895
@@ -1,4 +1,3 @@
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
// WITH_STDLIB
// ISSUE: KT-38895