[FIR] Desugar unary plus and minus as part of integer literal

#KT-42016
This commit is contained in:
Dmitriy Novozhilov
2020-09-18 11:18:50 +03:00
parent a018847f85
commit 5efd533f55
13 changed files with 49 additions and 25 deletions
@@ -4,5 +4,5 @@ FILE: nonCommutativeRepeat.kt
R|<local>/x| = R|<local>/x|.R|kotlin/Int.minus|(Int(1)).R|kotlin/Int.minus|(Int(1))
R|<local>/x| = R|<local>/x|.R|kotlin/Int.div|(Int(1))
R|<local>/x| = Int(1).R|kotlin/Int.div|(R|<local>/x|)
R|<local>/x| = Int(1).R|kotlin/Int.unaryMinus|().R|kotlin/Int.plus|(R|<local>/x|)
R|<local>/x| = Int(-1).R|kotlin/Int.plus|(R|<local>/x|)
}
@@ -22,7 +22,7 @@ FILE: NoWarning.kt
lval a: R|kotlin/ranges/IntProgression| = Int(4).R|kotlin/ranges/downTo|(Int(3))
lval v: R|kotlin/Int| = Int(1)
when () {
Int(5).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/downTo|(Int(6).R|kotlin/Int.unaryMinus|()).R|kotlin/collections/contains|<R|kotlin/Int|>(R|<local>/v|) -> {
Int(-5).R|kotlin/ranges/downTo|(Int(-6)).R|kotlin/collections/contains|<R|kotlin/Int|>(R|<local>/v|) -> {
}
}
@@ -36,7 +36,7 @@ FILE: NoWarning.kt
lval a: R|kotlin/ranges/IntRange| = Int(3).R|kotlin/ranges/until|(Int(4))
lval v: R|kotlin/Int| = Int(1)
when () {
Int(5).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/until|(Int(4).R|kotlin/Int.unaryMinus|()).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
Int(-5).R|kotlin/ranges/until|(Int(-4)).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
}
}
@@ -19,7 +19,7 @@ FILE: Warning.kt
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
}
lval a: R|kotlin/ranges/IntProgression| = Int(3).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/downTo|(Int(4))
lval a: R|kotlin/ranges/IntProgression| = Int(-3).R|kotlin/ranges/downTo|(Int(4))
lval v: R|kotlin/Int| = Int(1)
when () {
Int(0).R|kotlin/ranges/downTo|(Int(6)).R|kotlin/collections/contains|<R|kotlin/Int|>(R|<local>/v|) -> {
@@ -36,7 +36,7 @@ FILE: Warning.kt
lval a: R|kotlin/ranges/IntRange| = Int(4).R|kotlin/ranges/until|(Int(3))
lval v: R|kotlin/Int| = Int(1)
when () {
Int(5).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/until|(Int(5).R|kotlin/Int.unaryMinus|()).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
Int(-5).R|kotlin/ranges/until|(Int(-5)).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
}
}
@@ -32,7 +32,7 @@ FILE: operatorsOverLiterals.kt
R|/takeByte|(Byte(1).R|kotlin/Byte.plus|(Byte(1)))
<Inapplicable(INAPPLICABLE): /takeByte>#(Int(1).R|kotlin/Int.plus|(Int(127)))
R|/takeByte|(Byte(1).R|kotlin/Byte.minus|(Byte(1)))
<Inapplicable(INAPPLICABLE): /takeByte>#(Int(100).R|kotlin/Int.unaryMinus|().R|kotlin/Int.minus|(Int(100)))
<Inapplicable(INAPPLICABLE): /takeByte>#(Int(-100).R|kotlin/Int.minus|(Int(100)))
R|/takeByte|(Byte(10).R|kotlin/Byte.times|(Byte(10)))
<Inapplicable(INAPPLICABLE): /takeByte>#(Int(100).R|kotlin/Int.times|(Int(100)))
<Unresolved name: taleByte>#(Int(10).R|kotlin/Int.div|(Int(10)))
@@ -46,8 +46,8 @@ FILE: operatorsOverLiterals.kt
<Inapplicable(INAPPLICABLE): /takeByte>#(Int(512).R|kotlin/Int.xor|(Int(511)))
}
public final fun test_5(): R|kotlin/Unit| {
R|/takeByte|(Byte(1).R|kotlin/Byte.unaryMinus|())
R|/takeByte|(Byte(1).R|kotlin/Byte.unaryPlus|())
R|/takeByte|(Byte(-1))
R|/takeByte|(Byte(1))
R|/takeByte|(Byte(1).R|<local>/inv|())
}
public final fun test_6(): R|kotlin/Unit| {
@@ -6,8 +6,8 @@ FILE: jvm.kt
public final fun test(): R|kotlin/Unit| {
lval res1: R|kotlin/Boolean| = this@R|/A|.R|/Some.foo|(Int(1))
lval res2: R|kotlin/Boolean| = this@R|/A|.R|/Some.foo|(Int(1).R|kotlin/Int.unaryMinus|())
lval res3: R|ft<kotlin/Array<ft<kotlin/String, kotlin/String?>!>, kotlin/Array<out ft<kotlin/String, kotlin/String?>!>?>!| = this@R|/A|.R|/Some.bar|(R|kotlin/intArrayOf|(vararg(Int(0), Int(2), Int(2).R|kotlin/Int.unaryMinus|())))
lval res2: R|kotlin/Boolean| = this@R|/A|.R|/Some.foo|(Int(-1))
lval res3: R|ft<kotlin/Array<ft<kotlin/String, kotlin/String?>!>, kotlin/Array<out ft<kotlin/String, kotlin/String?>!>?>!| = this@R|/A|.R|/Some.bar|(R|kotlin/intArrayOf|(vararg(Int(0), Int(2), Int(-2))))
}
}