IR: slightly fix kotlin-like dumping of super qualifiers

This commit is contained in:
Mikhail Glukhikh
2022-06-15 12:04:59 +02:00
committed by Space
parent b0a6508d4b
commit 8ae47d4c4d
35 changed files with 95 additions and 68 deletions
@@ -966,9 +966,8 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
} }
superQualifierSymbol?.let { superQualifierSymbol?.let {
// TODO should we print super classifier somehow?
// TODO which supper? smart mode? // TODO which supper? smart mode?
p.printWithNoIndent("super") p.printWithNoIndent("super<${it.owner.name}>")
} }
dispatchReceiver?.let { dispatchReceiver?.let {
@@ -1109,12 +1108,11 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
// it's not valid kotlin // it's not valid kotlin
receiver?.accept(this@KotlinLikeDumper, data) receiver?.accept(this@KotlinLikeDumper, data)
superQualifierSymbol?.let { superQualifierSymbol?.let {
// TODO should we print super classifier somehow?
// TODO which supper? smart mode? // TODO which supper? smart mode?
// TODO super and receiver at the same time:
// compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.kt
// it's not valid kotlin // it's not valid kotlin
p.printWithNoIndent("super") if (receiver != null) p.printWithNoIndent("(")
p.printWithNoIndent("super<${it.owner.name}>")
if (receiver != null) p.printWithNoIndent(")")
} }
if (receiver != null || superQualifierSymbol != null) { if (receiver != null || superQualifierSymbol != null) {
@@ -10,7 +10,7 @@ open enum class A : Enum<A> {
} }
override fun f(): String { override fun f(): String {
return super.f().plus(other = "#Y") return super<A>.f().plus(other = "#Y")
} }
} }
@@ -58,3 +58,4 @@ open enum class A : Enum<A> {
fun valueOf(value: String): A /* Synthetic body for ENUM_VALUEOF */ fun valueOf(value: String): A /* Synthetic body for ENUM_VALUEOF */
} }
@@ -10,7 +10,7 @@ open enum class A : Enum<A> {
} }
override fun f(): String { override fun f(): String {
return super.f().plus(other = "#Y") return super<A>.f().plus(other = "#Y")
} }
} }
@@ -20,7 +20,7 @@ class K2 : JFoo {
} }
override fun foo(): String { override fun foo(): String {
return super.foo() /*!! String */ return super<JFoo>.foo() /*!! String */
} }
} }
@@ -42,7 +42,7 @@ class K4 : JUnrelatedFoo, IFoo {
} }
override fun foo(): @FlexibleNullability String? { override fun foo(): @FlexibleNullability String? {
return super.foo() return super<JUnrelatedFoo>.foo()
} }
} }
@@ -121,3 +121,4 @@ class TestK4 : IFoo {
local /* final field */ val <$$delegate_0>: K4 = K4() local /* final field */ val <$$delegate_0>: K4 = K4()
} }
@@ -20,7 +20,7 @@ class K2 : JFoo {
} }
override fun foo(): String { override fun foo(): String {
return super.foo() /*!! String */ return super<JFoo>.foo() /*!! String */
} }
} }
@@ -42,7 +42,7 @@ class K4 : JUnrelatedFoo, IFoo {
} }
override fun foo(): @FlexibleNullability String? { override fun foo(): @FlexibleNullability String? {
return super.foo() return super<JUnrelatedFoo>.foo()
} }
} }
@@ -116,3 +116,4 @@ class TestK4 : IFoo {
} }
} }
@@ -28,13 +28,14 @@ class CBoth : ILeft, IRight {
} }
override fun foo() { override fun foo() {
super.foo() super<ILeft>.foo()
super.foo() super<IRight>.foo()
} }
override val bar: Int override val bar: Int
override get(): Int { override get(): Int {
return super.<get-bar>().plus(other = super.<get-bar>()) return super<ILeft>.<get-bar>().plus(other = super<IRight>.<get-bar>())
} }
} }
@@ -28,13 +28,14 @@ class CBoth : ILeft, IRight {
} }
override fun foo() { override fun foo() {
super.foo() super<ILeft>.foo()
super.foo() super<IRight>.foo()
} }
override val bar: Int override val bar: Int
override get(): Int { override get(): Int {
return super.<get-bar>().plus(other = super.<get-bar>()) return super<ILeft>.<get-bar>().plus(other = super<IRight>.<get-bar>())
} }
} }
+4 -3
View File
@@ -13,7 +13,7 @@ open class Base {
open get open get
override fun hashCode(): Int { override fun hashCode(): Int {
return super.hashCode() return super<Any>.hashCode()
} }
} }
@@ -26,12 +26,13 @@ class Derived : Base {
} }
override fun foo() { override fun foo() {
super.foo() super<Base>.foo()
} }
override val bar: String override val bar: String
override get(): String { override get(): String {
return super.<get-bar>() return super<Base>.<get-bar>()
} }
} }
+4 -3
View File
@@ -13,7 +13,7 @@ open class Base {
open get open get
override fun hashCode(): Int { override fun hashCode(): Int {
return super.hashCode() return super<Any>.hashCode()
} }
} }
@@ -26,12 +26,13 @@ class Derived : Base {
} }
override fun foo() { override fun foo() {
super.foo() super<Base>.foo()
} }
override val bar: String override val bar: String
override get(): String { override get(): String {
return super.<get-bar>() return super<Base>.<get-bar>()
} }
} }
@@ -29,12 +29,13 @@ class Derived : Base, BaseI {
} }
override fun foo() { override fun foo() {
super.foo() super<Base>.foo()
} }
override val bar: String override val bar: String
override get(): String { override get(): String {
return super.<get-bar>() return super<Base>.<get-bar>()
} }
} }
@@ -29,12 +29,13 @@ class Derived : Base, BaseI {
} }
override fun foo() { override fun foo() {
super.foo() super<Base>.foo()
} }
override val bar: String override val bar: String
override get(): String { override get(): String {
return super.<get-bar>() return super<Base>.<get-bar>()
} }
} }
@@ -13,16 +13,17 @@ class C : B {
fun f(): @FlexibleNullability String? { fun f(): @FlexibleNullability String? {
return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? { return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? {
return <this>super.#x return <this>(super<A>).#x
} }
) )
} }
fun g(): @FlexibleNullability String? { fun g(): @FlexibleNullability String? {
return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? { return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? {
return <this>super.#y return <this>(super<B>).#y
} }
) )
} }
} }
@@ -13,16 +13,17 @@ class C : B {
fun f(): @FlexibleNullability String? { fun f(): @FlexibleNullability String? {
return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? { return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? {
return <this>super.#x return <this>(super<A>).#x
} }
) )
} }
fun g(): @FlexibleNullability String? { fun g(): @FlexibleNullability String? {
return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? { return eval<@FlexibleNullability String?>(f = local fun <anonymous>(): @FlexibleNullability String? {
return <this>super.#y return <this>(super<B>).#y
} }
) )
} }
} }
@@ -11,17 +11,18 @@ fun test2(mc: MutableCollection<String>) {
fun test3() { fun test3() {
{ // BLOCK { // BLOCK
val tmp0_safe_receiver: @FlexibleNullability PrintStream? = super.#out val tmp0_safe_receiver: @FlexibleNullability PrintStream? = super<System>.#out
when { when {
EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null
else -> tmp0_safe_receiver /*!! PrintStream */.println(p0 = "Hello,") else -> tmp0_safe_receiver /*!! PrintStream */.println(p0 = "Hello,")
} }
} /*~> Unit */ } /*~> Unit */
{ // BLOCK { // BLOCK
val tmp1_safe_receiver: @FlexibleNullability PrintStream? = super.#out val tmp1_safe_receiver: @FlexibleNullability PrintStream? = super<System>.#out
when { when {
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null
else -> tmp1_safe_receiver /*!! PrintStream */.println(p0 = "world!") else -> tmp1_safe_receiver /*!! PrintStream */.println(p0 = "world!")
} }
} /*~> Unit */ } /*~> Unit */
} }
+3 -2
View File
@@ -7,9 +7,10 @@ fun testEquals(a: Int, b: Int): Boolean {
} }
fun testJEqeqNull(): Boolean { fun testJEqeqNull(): Boolean {
return EQEQ(arg0 = super.#INT_NULL, arg1 = null) return EQEQ(arg0 = super<J>.#INT_NULL, arg1 = null)
} }
fun testJEqualsNull(): Boolean { fun testJEqualsNull(): Boolean {
return super.#INT_NULL /*!! Int */.equals(other = null) return super<J>.#INT_NULL /*!! Int */.equals(other = null)
} }
@@ -55,7 +55,7 @@ fun test(b: Boolean) {
else -> d2 else -> d2
} }
k.#f = 42 k.#f = 42
ksuper.#f /*~> Unit */ k(super<JFieldOwner>).#f /*~> Unit */
val md1: DerivedThroughMid1 = DerivedThroughMid1() val md1: DerivedThroughMid1 = DerivedThroughMid1()
val md2: DerivedThroughMid2 = DerivedThroughMid2() val md2: DerivedThroughMid2 = DerivedThroughMid2()
val mk: Mid = when { val mk: Mid = when {
@@ -63,5 +63,6 @@ fun test(b: Boolean) {
else -> md2 else -> md2
} }
mk.#f = 44 mk.#f = 44
mksuper.#f /*~> Unit */ mk(super<JFieldOwner>).#f /*~> Unit */
} }
@@ -54,14 +54,15 @@ fun test(b: Boolean) {
b -> d1 b -> d1
else -> d2 else -> d2
} }
k /*as JFieldOwner */super.#f = 42 k /*as JFieldOwner */(super<JFieldOwner>).#f = 42
k /*as JFieldOwner */super.#f /*~> Unit */ k /*as JFieldOwner */(super<JFieldOwner>).#f /*~> Unit */
val md1: DerivedThroughMid1 = DerivedThroughMid1() val md1: DerivedThroughMid1 = DerivedThroughMid1()
val md2: DerivedThroughMid2 = DerivedThroughMid2() val md2: DerivedThroughMid2 = DerivedThroughMid2()
val mk: Any = when { val mk: Any = when {
b -> md1 b -> md1
else -> md2 else -> md2
} }
mk /*as Mid */super.#f = 44 mk /*as Mid */(super<Mid>).#f = 44
mk /*as Mid */super.#f /*~> Unit */ mk /*as Mid */(super<JFieldOwner>).#f /*~> Unit */
} }
@@ -10,7 +10,7 @@ class Derived : Base {
} }
fun getValue(): Int { fun getValue(): Int {
return <this>super.#value return <this>(super<Base>).#value
} }
fun setValue(value: Int) { fun setValue(value: Int) {
@@ -18,3 +18,4 @@ class Derived : Base {
} }
} }
@@ -6,15 +6,16 @@ class Derived : Base {
} }
init { init {
<this>super.#value = 0 <this>(super<Derived>).#value = 0
} }
fun getValue(): Int { fun getValue(): Int {
return <this>super.#value return <this>(super<Base>).#value
} }
fun setValue(value: Int) { fun setValue(value: Int) {
<this>super.#value = value <this>(super<Derived>).#value = value
} }
} }
@@ -1,14 +1,14 @@
fun testFun() { fun testFun() {
super.#out /*!! PrintStream */.println(p0 = "testFun") super<System>.#out /*!! PrintStream */.println(p0 = "testFun")
} }
var testProp: Any var testProp: Any
get(): Any { get(): Any {
super.#out /*!! PrintStream */.println(p0 = "testProp/get") super<System>.#out /*!! PrintStream */.println(p0 = "testProp/get")
return 42 return 42
} }
set(value: Any) { set(value: Any) {
super.#out /*!! PrintStream */.println(p0 = "testProp/set") super<System>.#out /*!! PrintStream */.println(p0 = "testProp/set")
} }
class TestClass { class TestClass {
@@ -21,14 +21,15 @@ class TestClass {
val test: Int val test: Int
field = when { field = when {
else -> { // BLOCK else -> { // BLOCK
super.#out /*!! PrintStream */.println(p0 = "TestClass/test") super<System>.#out /*!! PrintStream */.println(p0 = "TestClass/test")
42 42
} }
} }
get get
init { init {
super.#out /*!! PrintStream */.println(p0 = "TestClass/init") super<System>.#out /*!! PrintStream */.println(p0 = "TestClass/init")
} }
} }
+2 -1
View File
@@ -53,7 +53,8 @@ class Test2 : J {
} }
init { init {
<this>super.#field = 42 <this>(super<Test2>).#field = 42
} }
} }
@@ -8,9 +8,10 @@ class Derived : Base {
fun setValue(v: Any) { fun setValue(v: Any) {
when { when {
v is String -> { // BLOCK v is String -> { // BLOCK
<this>super.#value = v /*as String */ <this>(super<Derived>).#value = v /*as String */
} }
} }
} }
} }
+1 -1
View File
@@ -13,7 +13,7 @@ class Owner<out T : JCTree> {
get(): String { get(): String {
var tree: JCTree = <this>.<get-tree>() var tree: JCTree = <this>.<get-tree>()
when { when {
tree is JCTypeApply -> return tree /*as JCTypeApply */super.#clazz /*!! String */ tree is JCTypeApply -> return tree /*as JCTypeApply */(super<JCTypeApply>).#clazz /*!! String */
} }
return "" return ""
} }
+2 -1
View File
@@ -14,10 +14,11 @@ class Owner<out T : JCTree> {
var tree: JCTree = <this>.<get-tree>() var tree: JCTree = <this>.<get-tree>()
when { when {
tree is JCTypeApply -> { // BLOCK tree is JCTypeApply -> { // BLOCK
return tree /*as JCTypeApply */super.#clazz /*!! String */ return tree /*as JCTypeApply */(super<JCTypeApply>).#clazz /*!! String */
} }
} }
return "" return ""
} }
} }
@@ -1,6 +1,7 @@
fun foo(movedPaths: MutableList<Couple<FilePath>>) { fun foo(movedPaths: MutableList<Couple<FilePath>>) {
movedPaths.forEach<Couple<FilePath>>(action = local fun <anonymous>(it: Couple<FilePath>) { movedPaths.forEach<Couple<FilePath>>(action = local fun <anonymous>(it: Couple<FilePath>) {
itsuper.#second.getName() /*~> Unit */ it(super<Pair>).#second.getName() /*~> Unit */
} }
) )
} }
@@ -1,6 +1,7 @@
fun foo(movedPaths: MutableList<Couple<FilePath>>) { fun foo(movedPaths: MutableList<Couple<FilePath>>) {
movedPaths.forEach<Couple<FilePath>>(action = local fun <anonymous>(it: Couple<FilePath>) { movedPaths.forEach<Couple<FilePath>>(action = local fun <anonymous>(it: Couple<FilePath>) {
itsuper.#second /*!! FilePath */.getName() /*~> Unit */ it(super<Pair>).#second /*!! FilePath */.getName() /*~> Unit */
} }
) )
} }
@@ -33,10 +33,11 @@ class MySet : Set<String> {
fun test() { fun test() {
f(s = s() /*!! String */) f(s = s() /*!! String */)
f(s = super.#STRING /*!! String */) f(s = super<J>.#STRING /*!! String */)
} }
fun testContains(m: MySet) { fun testContains(m: MySet) {
m.contains(element = super.#STRING /*!! String */) /*~> Unit */ m.contains(element = super<J>.#STRING /*!! String */) /*~> Unit */
m.contains(element = "abc") /*~> Unit */ m.contains(element = "abc") /*~> Unit */
} }
@@ -15,7 +15,7 @@ class Derived : A, IFoo {
} }
override fun foo(): @FlexibleNullability String? { override fun foo(): @FlexibleNullability String? {
return super.foo() return super<A>.foo()
} }
} }
@@ -15,7 +15,7 @@ class Derived : A, IFoo {
} }
override fun foo(): @FlexibleNullability String? { override fun foo(): @FlexibleNullability String? {
return super.foo() return super<A>.foo()
} }
} }
@@ -1,7 +1,8 @@
fun test1(): Boolean { fun test1(): Boolean {
return super.#BOOL_NULL /*!! Boolean */.equals(other = null) return super<J>.#BOOL_NULL /*!! Boolean */.equals(other = null)
} }
fun test2(): Boolean { fun test2(): Boolean {
return boolNull() /*!! Boolean */.equals(other = null) return boolNull() /*!! Boolean */.equals(other = null)
} }
@@ -4,5 +4,6 @@ fun <T> f(x: T): Int where T : CharSequence?, T : Comparable<T> {
fun test() { fun test() {
f<@FlexibleNullability String?>(x = s()) /*~> Unit */ f<@FlexibleNullability String?>(x = s()) /*~> Unit */
f<@FlexibleNullability String?>(x = super.#STRING) /*~> Unit */ f<@FlexibleNullability String?>(x = super<J>.#STRING) /*~> Unit */
} }
@@ -4,5 +4,6 @@ fun <T> f(x: T): Int where T : CharSequence, T : Comparable<T> {
fun test() { fun test() {
f<@FlexibleNullability String?>(x = s()) /*~> Unit */ f<@FlexibleNullability String?>(x = s()) /*~> Unit */
f<@FlexibleNullability String?>(x = super.#STRING) /*~> Unit */ f<@FlexibleNullability String?>(x = super<J>.#STRING) /*~> Unit */
} }
@@ -10,5 +10,6 @@ fun <T> f(x: T): Int? where T : CharSequence?, T : Comparable<T>? {
fun test() { fun test() {
f<@FlexibleNullability String?>(x = s()) /*~> Unit */ f<@FlexibleNullability String?>(x = s()) /*~> Unit */
f<@FlexibleNullability String?>(x = super.#STRING) /*~> Unit */ f<@FlexibleNullability String?>(x = super<J>.#STRING) /*~> Unit */
} }
@@ -6,6 +6,6 @@ fun testSetField(a: Any, b: Any) {
fun testGetField(a: Any): String { fun testGetField(a: Any): String {
a as JCell<String> /*~> Unit */ a as JCell<String> /*~> Unit */
return a /*as JCell<String> */super.#value /*!! String */ return a /*as JCell<String> */(super<JCell>).#value /*!! String */
} }
@@ -1,10 +1,11 @@
fun testSetField(a: Any, b: Any) { fun testSetField(a: Any, b: Any) {
a as JCell<String> /*~> Unit */ a as JCell<String> /*~> Unit */
b as String /*~> Unit */ b as String /*~> Unit */
a /*as JCell<String> */super.#value = b /*as String */ a /*as JCell<String> */(super<JCell>).#value = b /*as String */
} }
fun testGetField(a: Any): String { fun testGetField(a: Any): String {
a as JCell<String> /*~> Unit */ a as JCell<String> /*~> Unit */
return a /*as JCell<String> */super.#value /*!! String */ return a /*as JCell<String> */(super<JCell>).#value /*!! String */
} }