FIR: Improve rendering for type operators

This commit is contained in:
Simon Ogorodnik
2019-03-14 17:49:34 +03:00
parent 27687602f8
commit 24041828a9
7 changed files with 20 additions and 10 deletions
@@ -2,7 +2,7 @@ FILE: genericFunctions.kt
public? final? interface Any { public? final? interface Any {
} }
<reified T : Any> public? final? inline fun Any.safeAs(): T? { <reified T : Any> public? final? inline fun Any.safeAs(): T? {
^safeAs as?/T(this#) ^safeAs (this# as? T)
} }
public? abstract class Summator { public? abstract class Summator {
public? constructor(): super<kotlin/Any>() public? constructor(): super<kotlin/Any>()
@@ -52,7 +52,7 @@ FILE: branches.kt
in($subj$, rangeTo#(Int(1), Int(2))) -> { in($subj$, rangeTo#(Int(1), Int(2))) -> {
String(Fail) String(Fail)
} }
is/Number($subj$) -> { ($subj$ is Number) -> {
String(Number) String(Number)
} }
else -> { else -> {
@@ -11,6 +11,6 @@ FILE: modifications.kt
this# += String(Omega) this# += String(Omega)
} }
public? final? fun Any.modify(): kotlin/Unit { public? final? fun Any.modify(): kotlin/Unit {
lval <complex-set>: <implicit> = as/List<Int>(this#) lval <complex-set>: <implicit> = (this# as List<Int>)
<complex-set># += Int(42) <complex-set># += Int(42)
} }
@@ -2,14 +2,14 @@ FILE: typeOperators.kt
public? final? interface IThing { public? final? interface IThing {
} }
public? final? fun test1(x: Any): <implicit> { public? final? fun test1(x: Any): <implicit> {
^test1 is/IThing(x#) ^test1 (x# is IThing)
} }
public? final? fun test2(x: Any): <implicit> { public? final? fun test2(x: Any): <implicit> {
^test2 !is/IThing(x#) ^test2 (x# !is IThing)
} }
public? final? fun test3(x: Any): <implicit> { public? final? fun test3(x: Any): <implicit> {
^test3 as/IThing(x#) ^test3 (x# as IThing)
} }
public? final? fun test4(x: Any): <implicit> { public? final? fun test4(x: Any): <implicit> {
^test4 as?/IThing(x#) ^test4 (x# as? IThing)
} }
+2 -2
View File
@@ -8,8 +8,8 @@ FILE: lists.kt
} }
public final fun R|kotlin/collections/List<kotlin/String>|.convert(): R|MyStringList| { public final fun R|kotlin/collections/List<kotlin/String>|.convert(): R|MyStringList| {
^convert as/R|MyStringList|(this#) ^convert (this# as R|MyStringList|)
} }
public final fun ret(l: R|kotlin/collections/MutableList<kotlin/String>|): R|MyMutableStringList| { public final fun ret(l: R|kotlin/collections/MutableList<kotlin/String>|): R|MyMutableStringList| {
^ret as/R|MyMutableStringList|(this#) ^ret (this# as R|MyMutableStringList|)
} }
+1 -1
View File
@@ -2,7 +2,7 @@ FILE: genericFunctions.kt
public abstract interface Any { public abstract interface Any {
} }
<reified T : R|Any|> public final inline fun R|Any|.safeAs(): R|T|? { <reified T : R|Any|> public final inline fun R|Any|.safeAs(): R|T|? {
^safeAs as?/R|T|(this#) ^safeAs (this# as? R|T|)
} }
public abstract class Summator { public abstract class Summator {
public constructor(): super<R|kotlin/Any|>() public constructor(): super<R|kotlin/Any|>()
@@ -607,6 +607,16 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
print(")") print(")")
} }
override fun visitTypeOperatorCall(typeOperatorCall: FirTypeOperatorCall) {
print("(")
typeOperatorCall.argument.accept(this)
print(" ")
print(typeOperatorCall.operation.operator)
print(" ")
typeOperatorCall.typeRef.accept(this)
print(")")
}
override fun visitAnnotationCall(annotationCall: FirAnnotationCall) { override fun visitAnnotationCall(annotationCall: FirAnnotationCall) {
print("@") print("@")
annotationCall.useSiteTarget?.let { annotationCall.useSiteTarget?.let {