[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:
Dmitriy Novozhilov
2022-01-25 12:41:04 +03:00
committed by teamcity
parent cc86ca2a0f
commit 52b72a7dac
98 changed files with 1318 additions and 232 deletions
@@ -8,6 +8,6 @@ annotation class Ann(
val l: Long
)
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>, 1 / 1, <!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>) class MyClass
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>, 1 / 1, 1 / 1) class MyClass
// EXPECTED: @Ann(b = 1.toByte(), i = 1, l = 1.toLong(), s = 1.toShort())
@@ -7,6 +7,6 @@ annotation class Ann(
val l3: Long
)
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>, java.lang.Long.MAX_VALUE + 1 - 1, java.lang.Long.MAX_VALUE - 1) class MyClass
@Ann(1 + 1, java.lang.Long.MAX_VALUE + 1 - 1, java.lang.Long.MAX_VALUE - 1) class MyClass
// EXPECTED: @Ann(l1 = 2.toLong(), l2 = 9223372036854775807.toLong(), l3 = 9223372036854775806.toLong())
@@ -8,6 +8,6 @@ annotation class Ann(
val l: Long
)
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>, 1 * 1, <!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>) class MyClass
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>, 1 * 1, 1 * 1) class MyClass
// EXPECTED: @Ann(b = 1.toByte(), i = 1, l = 1.toLong(), s = 1.toShort())
@@ -8,6 +8,6 @@ annotation class Ann(
val l: Long
)
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 - 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 - 1<!>, 1 - 1, <!ARGUMENT_TYPE_MISMATCH!>1 - 1<!>) class MyClass
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 - 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 - 1<!>, 1 - 1, 1 - 1) class MyClass
// EXPECTED: @Ann(b = 0.toByte(), i = 0, l = 0.toLong(), s = 0.toShort())
@@ -8,6 +8,6 @@ annotation class Ann(
val l: Long
)
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>, 1 % 1, <!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>) class MyClass
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>, 1 % 1, 1 % 1) class MyClass
// EXPECTED: @Ann(b = 0.toByte(), i = 0, l = 0.toLong(), s = 0.toShort())
@@ -8,6 +8,6 @@ annotation class Ann(
val l: Long
)
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>, 1 + 1, <!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>) class MyClass
@Ann(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>, <!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>, 1 + 1, 1 + 1) class MyClass
// EXPECTED: @Ann(b = 2.toByte(), i = 2, l = 2.toLong(), s = 2.toShort())
@@ -17,7 +17,7 @@ fun test() {
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 - 1.toLong()<!>)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 - 1.toShort()<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 - 1<!>)
fooLong(1 - 1)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 - 1.toInt()<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 - 1.toByte()<!>)
fooLong(1 - 1.toLong())
@@ -1,5 +1,5 @@
val p1: Int = 1 - 1
val p2: Long = <!TYPE_MISMATCH!>1 - 1<!>
val p2: Long = 1 - 1
val p3: Byte = <!TYPE_MISMATCH!>1 - 1<!>
val p4: Short = <!TYPE_MISMATCH!>1 - 1<!>
@@ -7,21 +7,21 @@ fun fooShort(p: Short) = p
fun test() {
fooInt(1 + 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>)
fooLong(1 + 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>)
fooInt(1 * 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>)
fooLong(1 * 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 * 1<!>)
fooInt(1 / 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>)
fooLong(1 / 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 / 1<!>)
fooInt(1 % 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>)
fooLong(1 % 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>)
}
@@ -7,21 +7,21 @@ fun fooShort(p: Short) = p
fun test() {
fooInt(1.plus(1))
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1.plus(1)<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1.plus(1)<!>)
fooLong(1.plus(1))
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1.plus(1)<!>)
fooInt(1.times(1))
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1.times(1)<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1.times(1)<!>)
fooLong(1.times(1))
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1.times(1)<!>)
fooInt(1.div(1))
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1.div(1)<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1.div(1)<!>)
fooLong(1.div(1))
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1.div(1)<!>)
fooInt(1.rem(1))
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1.rem(1)<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1.rem(1)<!>)
fooLong(1.rem(1))
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1.rem(1)<!>)
}
@@ -7,21 +7,21 @@ fun fooShort(p: Short) = p
fun test() {
fooInt(1 <!INFIX_MODIFIER_REQUIRED!>plus<!> 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>plus<!> 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>plus<!> 1<!>)
fooLong(1 <!INFIX_MODIFIER_REQUIRED!>plus<!> 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>plus<!> 1<!>)
fooInt(1 <!INFIX_MODIFIER_REQUIRED!>times<!> 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>times<!> 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>times<!> 1<!>)
fooLong(1 <!INFIX_MODIFIER_REQUIRED!>times<!> 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>times<!> 1<!>)
fooInt(1 <!INFIX_MODIFIER_REQUIRED!>div<!> 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>div<!> 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>div<!> 1<!>)
fooLong(1 <!INFIX_MODIFIER_REQUIRED!>div<!> 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>div<!> 1<!>)
fooInt(1 <!INFIX_MODIFIER_REQUIRED!>rem<!> 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>rem<!> 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>rem<!> 1<!>)
fooLong(1 <!INFIX_MODIFIER_REQUIRED!>rem<!> 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 <!INFIX_MODIFIER_REQUIRED!>rem<!> 1<!>)
}
@@ -0,0 +1,13 @@
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
val p1: Byte = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
val p2: Short = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
val p3: Int = (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 b3: Int = (1.toInt() + 2) * 2
val b4: Long = (1.toLong() + 2) * 2
val i1: Int = (1.toByte() + 2) * 2
val i2: Int = (1.toShort() + 2) * 2
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
val p1: Byte = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
val p2: Short = <!TYPE_MISMATCH!>(1 + 2) * 2<!>
@@ -0,0 +1,65 @@
// SKIP_TXT
// FIR_DUMP
// ISSUE: KT-38895, KT-50996, KT-51000
interface A
interface B
fun takeByte(x: Byte) {}
fun takeInt(x: Int) {}
fun takeNullableInt(x: Int) {}
fun takeLong(x: Long) {}
fun takeNullableLong(x: Long) {}
fun takeOverloaded(x: Int): A = null!! // (1)
fun takeOverloaded(x: Long): B = null!! // (2)
fun takeA(a: A) {}
fun takeB(b: B) {}
fun test_constants() {
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>) // error
takeInt(1 + 1 + 1) // OK
takeNullableInt(1 + 1 + 1) // OK
takeLong(1 + 1 + 1) // will be OK with implicit widening conversion
takeNullableLong(1 + 1 + 1) // will be OK with implicit widening conversion
val x = takeOverloaded(2147483648 - 1 + 1) // now resolved to (1), will be resolved to (2)
takeA(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
takeB(x)
}
val topLevelIntProperty: Int = 1 + 1 + 1
val topLevelLongProperty: Long = 1 + 1 + 1
val topLevelImplicitIntProperty = 1 + 1 + 1
val topLevelImplicitLongProperty = 3000000000 * 2 + 1
fun testTopLevelProperties() {
// OK
takeInt(topLevelIntProperty)
takeLong(topLevelLongProperty)
takeInt(topLevelImplicitIntProperty)
takeLong(topLevelImplicitLongProperty)
// no conversion for properties
takeLong(<!ARGUMENT_TYPE_MISMATCH!>topLevelIntProperty<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>topLevelImplicitIntProperty<!>)
}
fun testLocalProperties() {
val localIntProperty: Int = 1 + 1
val localLongProperty: Long = 1 + 1
val localImplicitIntProperty = 1 + 1
val localImplicitLongProperty = 3000000000 * 2
// OK
takeInt(localIntProperty)
takeLong(localLongProperty)
takeInt(localImplicitIntProperty)
takeLong(localImplicitLongProperty)
// no conversion for properties
takeLong(<!ARGUMENT_TYPE_MISMATCH!>localIntProperty<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>localImplicitIntProperty<!>)
}
@@ -0,0 +1,63 @@
FILE: intToLongConversion.fir.kt
public abstract interface A : R|kotlin/Any| {
}
public abstract interface B : R|kotlin/Any| {
}
public final fun takeByte(x: R|kotlin/Byte|): R|kotlin/Unit| {
}
public final fun takeInt(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun takeNullableInt(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun takeLong(x: R|kotlin/Long|): R|kotlin/Unit| {
}
public final fun takeNullableLong(x: R|kotlin/Long|): R|kotlin/Unit| {
}
public final fun takeOverloaded(x: R|kotlin/Int|): R|A| {
^takeOverloaded Null(null)!!
}
public final fun takeOverloaded(x: R|kotlin/Long|): R|B| {
^takeOverloaded Null(null)!!
}
public final fun takeA(a: R|A|): R|kotlin/Unit| {
}
public final fun takeB(b: R|B|): R|kotlin/Unit| {
}
public final fun test_constants(): R|kotlin/Unit| {
<Inapplicable(INAPPLICABLE): /takeByte>#(Int(1).R|kotlin/Int.plus|(Int(1)))
R|/takeInt|(Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.plus|(Int(1)))
R|/takeNullableInt|(Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.plus|(Int(1)))
R|/takeLong|(Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.toLong|())
R|/takeNullableLong|(Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.toLong|())
lval x: R|B| = R|/takeOverloaded|(Long(2147483648).R|kotlin/Long.minus|(Int(1)).R|kotlin/Long.plus|(Int(1)))
<Inapplicable(INAPPLICABLE): /takeA>#(R|<local>/x|)
R|/takeB|(R|<local>/x|)
}
public final val topLevelIntProperty: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.plus|(Int(1))
public get(): R|kotlin/Int|
public final val topLevelLongProperty: R|kotlin/Long| = Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.toLong|()
public get(): R|kotlin/Long|
public final val topLevelImplicitIntProperty: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.plus|(Int(1))
public get(): R|kotlin/Int|
public final val topLevelImplicitLongProperty: R|kotlin/Long| = Long(3000000000).R|kotlin/Long.times|(Int(2)).R|kotlin/Long.plus|(Int(1))
public get(): R|kotlin/Long|
public final fun testTopLevelProperties(): R|kotlin/Unit| {
R|/takeInt|(R|/topLevelIntProperty|)
R|/takeLong|(R|/topLevelLongProperty|)
R|/takeInt|(R|/topLevelImplicitIntProperty|)
R|/takeLong|(R|/topLevelImplicitLongProperty|)
<Inapplicable(INAPPLICABLE): /takeLong>#(R|/topLevelIntProperty|)
<Inapplicable(INAPPLICABLE): /takeLong>#(R|/topLevelImplicitIntProperty|)
}
public final fun testLocalProperties(): R|kotlin/Unit| {
lval localIntProperty: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1))
lval localLongProperty: R|kotlin/Long| = Int(1).R|kotlin/Int.plus|(Int(1)).R|kotlin/Int.toLong|()
lval localImplicitIntProperty: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1))
lval localImplicitLongProperty: R|kotlin/Long| = Long(3000000000).R|kotlin/Long.times|(Int(2))
R|/takeInt|(R|<local>/localIntProperty|)
R|/takeLong|(R|<local>/localLongProperty|)
R|/takeInt|(R|<local>/localImplicitIntProperty|)
R|/takeLong|(R|<local>/localImplicitLongProperty|)
<Inapplicable(INAPPLICABLE): /takeLong>#(R|<local>/localIntProperty|)
<Inapplicable(INAPPLICABLE): /takeLong>#(R|<local>/localImplicitIntProperty|)
}
@@ -0,0 +1,65 @@
// SKIP_TXT
// FIR_DUMP
// ISSUE: KT-38895, KT-50996, KT-51000
interface A
interface B
fun takeByte(x: Byte) {}
fun takeInt(x: Int) {}
fun takeNullableInt(x: Int) {}
fun takeLong(x: Long) {}
fun takeNullableLong(x: Long) {}
fun takeOverloaded(x: Int): A = null!! // (1)
fun takeOverloaded(x: Long): B = null!! // (2)
fun takeA(a: A) {}
fun takeB(b: B) {}
fun test_constants() {
takeByte(<!INTEGER_OPERATOR_RESOLVE_WILL_CHANGE!>1 + 1<!>) // error
takeInt(1 + 1 + 1) // OK
takeNullableInt(1 + 1 + 1) // OK
takeLong(1 + 1 + 1) // will be OK with implicit widening conversion
takeNullableLong(1 + 1 + 1) // will be OK with implicit widening conversion
val x = takeOverloaded(<!INTEGER_OVERFLOW!>2147483648 - 1 + 1<!>) // now resolved to (1), will be resolved to (2)
takeA(x)
takeB(<!TYPE_MISMATCH!>x<!>)
}
val topLevelIntProperty: Int = 1 + 1 + 1
val topLevelLongProperty: Long = 1 + 1 + 1
val topLevelImplicitIntProperty = 1 + 1 + 1
val topLevelImplicitLongProperty = 3000000000 * 2 + 1
fun testTopLevelProperties() {
// OK
takeInt(topLevelIntProperty)
takeLong(topLevelLongProperty)
takeInt(topLevelImplicitIntProperty)
takeLong(topLevelImplicitLongProperty)
// no conversion for properties
takeLong(<!TYPE_MISMATCH!>topLevelIntProperty<!>)
takeLong(<!TYPE_MISMATCH!>topLevelImplicitIntProperty<!>)
}
fun testLocalProperties() {
val localIntProperty: Int = 1 + 1
val localLongProperty: Long = 1 + 1
val localImplicitIntProperty = 1 + 1
val localImplicitLongProperty = 3000000000 * 2
// OK
takeInt(localIntProperty)
takeLong(localLongProperty)
takeInt(localImplicitIntProperty)
takeLong(localImplicitLongProperty)
// no conversion for properties
takeLong(<!TYPE_MISMATCH!>localIntProperty<!>)
takeLong(<!TYPE_MISMATCH!>localImplicitIntProperty<!>)
}
@@ -0,0 +1,24 @@
// FIR_IDENTICAL
// ISSUE: KT-51003
interface Assert<T>
fun <T> createAssert(value: T): Assert<T> = null!!
fun <A, B : Comparable<A>> Assert<B>.isGreaterThanOrEqualTo(other: A) {}
fun test_1(long: Long) {
// FE 1.0: OK
// FIR: ARGUMENT_TYPE_MISMATCH
createAssert(long).isGreaterThanOrEqualTo(10 * 10)
}
fun getNullableLong(): Long? = null
fun takeLong(x: Long) {}
fun test_2() {
val x = getNullableLong() ?: 10 * 60
takeLong(x)
// FE 1.0 infers type of `x` to `Long`
// FIR infers it to `Number` as `CST(Long, Int)`
}
@@ -0,0 +1,14 @@
package
public fun </*0*/ T> createAssert(/*0*/ value: T): Assert<T>
public fun getNullableLong(): kotlin.Long?
public fun takeLong(/*0*/ x: kotlin.Long): kotlin.Unit
public fun test_1(/*0*/ long: kotlin.Long): kotlin.Unit
public fun test_2(): kotlin.Unit
public fun </*0*/ A, /*1*/ B : kotlin.Comparable<A>> Assert<B>.isGreaterThanOrEqualTo(/*0*/ other: A): kotlin.Unit
public interface Assert</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,22 +0,0 @@
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
// ISSUE: Kt-47447, KT-47729
fun takeLong(value : Long) {}
fun takeInt(value : Int) {}
fun takeAny(value : Any) {}
fun takeLongX(value : Long?) {}
fun takeIntX(value : Int?) {}
fun takeAnyX(value : Any?) {}
fun <A> takeGeneric(value : A) {}
fun <A> takeGenericX(value : A?) {}
fun test_1() {
takeLong(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>) // ok
takeInt(1 + 1) // ok
takeAny(1 + 1) // ok
takeLongX(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>) // ok
takeIntX(1 + 1) // ok
takeAnyX(1 + 1) // ok
takeGeneric(1 + 1) // ok
takeGenericX(1 + 1) // ok
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
// ISSUE: Kt-47447, KT-47729
@@ -1,20 +0,0 @@
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
// ISSUE: Kt-47447, KT-47729
fun takeLong(x: Long) {}
object Foo {
var longProperty: Long = 0
infix fun infixOperator(x: Long) {}
}
// Should be ok in all places
fun test() {
takeLong(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>)
takeLong((<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>))
Foo.longProperty = 1 + 1
Foo.longProperty = (1 + 1)
Foo infixOperator <!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>
Foo infixOperator (<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
// ISSUE: Kt-47447, KT-47729
@@ -1,5 +0,0 @@
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
fun foo(ttlMillis: Long = <!TYPE_MISMATCH!>5 * 60 * 1000<!>) {}
const val cacheSize: Long = <!TYPE_MISMATCH!>4096 * 4<!>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
fun foo(ttlMillis: Long = 5 * 60 * 1000) {}
@@ -0,0 +1,6 @@
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
fun foo(ttlMillis: Long = 5 * 60 * 1000) {}
const val cacheSize: Long = 4096 * 4
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// LANGUAGE: +ApproximateIntegerLiteralTypesInReceiverPosition
fun foo(ttlMillis: Long = <!TYPE_MISMATCH!>5 * 60 * 1000<!>) {}
@@ -7,21 +7,21 @@ abstract class C<L> {
}
fun testLongDotCall(c1: C<Long>) {
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.plus(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.minus(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.times(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.div(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.rem(2)<!>)
c1.takeT(1.plus(2))
c1.takeT(1.minus(2))
c1.takeT(1.times(2))
c1.takeT(1.div(2))
c1.takeT(1.rem(2))
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.inc()<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.dec()<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.unaryPlus()<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.unaryMinus()<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.shl(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.shr(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.ushr(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.and(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.or(2)<!>)
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.xor(2)<!>)
c1.takeT(1.shl(2))
c1.takeT(1.shr(2))
c1.takeT(1.ushr(2))
c1.takeT(1.and(2))
c1.takeT(1.or(2))
c1.takeT(1.xor(2))
c1.takeT(<!ARGUMENT_TYPE_MISMATCH!>1.inv()<!>)
}
@@ -42,19 +42,19 @@ fun testByteDotCall(c3: C<Byte>) {
}
fun testLongOperatorInfixCall(c4: C<Long>) {
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 + 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 - 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 * 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 / 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 % 2<!>)
c4.takeT(1 + 2)
c4.takeT(1 - 2)
c4.takeT(1 * 2)
c4.takeT(1 / 2)
c4.takeT(1 % 2)
c4.takeT(+1)
c4.takeT(-1)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 shl 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 shr 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 ushr 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 and 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 or 2<!>)
c4.takeT(<!ARGUMENT_TYPE_MISMATCH!>1 xor 2<!>)
c4.takeT(1 shl 2)
c4.takeT(1 shr 2)
c4.takeT(1 ushr 2)
c4.takeT(1 and 2)
c4.takeT(1 or 2)
c4.takeT(1 xor 2)
}
fun testShortOperatorInfixCall(c5: C<Short>) {
@@ -41,24 +41,24 @@ fun testByteUnaryOperators() {
}
fun testLongBinaryOperators() {
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 + 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 - 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 * 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 / 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 % 1<!>)
takeLong(2 + 1)
takeLong(2 - 1)
takeLong(2 * 1)
takeLong(2 / 1)
takeLong(2 % 1)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.plus(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.minus(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.times(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.div(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.rem(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 shl 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 shr 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 ushr 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(<!ARGUMENT_TYPE_MISMATCH!>2 and 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 or 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 xor 1<!>)
takeLong(2 and 1)
takeLong(2 or 1)
takeLong(2 xor 1)
// positive
takeLong(2 * 100000000000)
@@ -42,24 +42,24 @@ fun testByteUnaryOperators() {
// all positive
fun testLongBinaryOperators() {
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 + 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 - 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 * 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 / 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 % 1<!>)
takeLong(2 + 1)
takeLong(2 - 1)
takeLong(2 * 1)
takeLong(2 / 1)
takeLong(2 % 1)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.plus(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.minus(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.times(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.div(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2.rem(1)<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 shl 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 shr 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 ushr 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(<!ARGUMENT_TYPE_MISMATCH!>2 and 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 or 1<!>)
takeLong(<!ARGUMENT_TYPE_MISMATCH!>2 xor 1<!>)
takeLong(2 and 1)
takeLong(2 or 1)
takeLong(2 xor 1)
takeLong(2 * 100000000000)
}
@@ -8,7 +8,7 @@ fun fooShort(p: Short) = p
fun test() {
fooInt(1 % 1)
fooByte(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>)
fooLong(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>)
fooLong(1 % 1)
fooShort(<!ARGUMENT_TYPE_MISMATCH!>1 % 1<!>)
}
@@ -13,8 +13,8 @@ val u3: UInt? = u1
val i0: Int = <!INITIALIZER_TYPE_MISMATCH!>1u<!>
val m0 = <!UNRESOLVED_REFERENCE!>-<!>1u
val m1: UInt = <!UNRESOLVED_REFERENCE!>-<!>1u
val m0 = <!NONE_APPLICABLE!>-<!>1u
val m1: UInt = <!NONE_APPLICABLE!>-<!>1u
val h1 = 0xFFu
val h2: UShort = 0xFFu