Raw FIR: fix unary operators (now convention calls use receivers)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
77e83dd8cf
commit
73b1676a03
@@ -1216,14 +1216,15 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
||||
calleeReference = FirSimpleNamedReference(
|
||||
this@RawFirBuilder.session, expression.operationReference, conventionCallName
|
||||
)
|
||||
explicitReceiver = argument.toFirExpression("No operand")
|
||||
}
|
||||
} else {
|
||||
val firOperation = operationToken.toFirOperation()
|
||||
FirOperatorCallImpl(
|
||||
session, expression, firOperation
|
||||
)
|
||||
}.apply {
|
||||
arguments += argument.toFirExpression("No operand")
|
||||
).apply {
|
||||
arguments += argument.toFirExpression("No operand")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ FILE: namedArgument.kt
|
||||
foo#()
|
||||
foo#(String(Alpha), Boolean(false), Double(2.71))
|
||||
foo#(first = String(Hello), second = Boolean(true))
|
||||
foo#(third = unaryMinus#(Double(1.0)), first = String(123))
|
||||
foo#(third = Double(1.0).unaryMinus#(), first = String(123))
|
||||
foo#(ERROR_EXPR(Argument is absent))
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ FILE: unary.kt
|
||||
}
|
||||
|
||||
when () {
|
||||
not#(==(x#, Int(0))) -> {
|
||||
==(x#, Int(0)).not#() -> {
|
||||
println#(String(000))
|
||||
}
|
||||
else -> {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
7class U {
|
||||
operator fun contains(g: String): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun foo(u: U) {
|
||||
val b = false
|
||||
val i = 10
|
||||
val x = -i
|
||||
val y = !b
|
||||
val z = -1.0
|
||||
val w = +i
|
||||
|
||||
val g = "" !in u
|
||||
val f = "" !is Boolean
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
FILE: unaryOperators.kt
|
||||
public final class U : R|kotlin/Any| {
|
||||
public constructor(): R|U| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun contains(g: R|kotlin/String|): R|kotlin/Boolean| {
|
||||
^contains Boolean(false)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun foo(u: R|U|): R|kotlin/Unit| {
|
||||
lval b: R|kotlin/Boolean| = Boolean(false)
|
||||
lval i: R|kotlin/Int| = Int(10)
|
||||
lval x: R|kotlin/Int| = R|<local>/i|.R|kotlin/Int.unaryMinus|()
|
||||
lval y: R|kotlin/Boolean| = R|<local>/b|.R|kotlin/Boolean.not|()
|
||||
lval z: R|kotlin/Double| = Double(1.0).R|kotlin/Double.unaryMinus|()
|
||||
lval w: R|kotlin/Int| = R|<local>/i|.R|kotlin/Int.unaryPlus|()
|
||||
lval g: R|kotlin/Boolean| = R|<local>/u|.R|/U.contains|(String()).R|kotlin/Boolean.not|()
|
||||
lval f: R|kotlin/Boolean| = (String() !is R|kotlin/Boolean|)
|
||||
}
|
||||
Generated
+5
@@ -43,4 +43,9 @@ public class FirResolveTestCaseWithStdlibGenerated extends AbstractFirResolveTes
|
||||
public void testReflectionClass() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unaryOperators.kt")
|
||||
public void testUnaryOperators() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/unaryOperators.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user