Generate method calls for inline classes through IC, not IC$Erased

IC extends IC$Erased, so it should be fine.
This commit is contained in:
Dmitry Petrov
2018-08-30 12:29:41 +03:00
parent 3080b65f7d
commit 80a67477db
10 changed files with 100 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ inline class Foo(val x: Int) {
}
}
// 1 INVOKESTATIC Foo\$Erased.empty \(I\)V
// 1 INVOKESTATIC Foo\$Erased.withParam \(ILjava/lang/String;\)V
// 1 INVOKESTATIC Foo\$Erased.withInlineClassParam-1e4ch6lh \(II\)V
// 1 INVOKESTATIC Foo\.empty \(I\)V
// 1 INVOKESTATIC Foo\.withParam \(ILjava/lang/String;\)V
// 1 INVOKESTATIC Foo\.withInlineClassParam-1e4ch6lh \(II\)V
// 5 INVOKEVIRTUAL

View File

@@ -0,0 +1,14 @@
// !LANGUAGE: +InlineClasses
// FILE: Z.kt
inline class Z(val x: Int)
// FILE: test.kt
fun testZ(z: Z) = z.equals(z)
fun testZ(z: Z, a: Any?) = z.equals(a)
fun testNZ(z: Z?) = z?.equals(z)
// @TestKt.class:
// 0 INVOKESTATIC Z\$Erased\.equals
// 0 INVOKESTATIC Z\-Erased\.equals
// 3 INVOKESTATIC Z\.equals \(ILjava/lang/Object;\)Z

View File

@@ -0,0 +1,13 @@
// !LANGUAGE: +InlineClasses
// FILE: Z.kt
inline class Z(val x: Int)
// FILE: Test.kt
fun testZ(z: Z) = z.hashCode()
fun testNZ(z: Z?) = z?.hashCode()
// @TestKt.class:
// 0 INVOKESTATIC Z\$Erased\.hashCode
// 0 INVOKESTATIC Z\-Erased\.hashCode
// 2 INVOKESTATIC Z\.hashCode \(I\)I

View File

@@ -24,7 +24,7 @@ fun test(a: Any, b: Any?) {
// 2 INSTANCEOF UInt
// 2 CHECKCAST UInt
// 1 INVOKEVIRTUAL UInt.unbox
// 1 INVOKESTATIC UInt\$Erased.member
// 1 INVOKEVIRTUAL UInt\.unbox
// 1 INVOKESTATIC UInt\.member
// 0 intValue

View File

@@ -14,5 +14,5 @@ fun test(f: Foo) {
f.notInlineInc() // one here
}
// 0 INVOKESTATIC Foo\$Erased.inlineInc
// 1 INVOKESTATIC Foo\$Erased.notInlineInc
// 0 INVOKESTATIC Foo\.inlineInc
// 1 INVOKESTATIC Foo\.notInlineInc

View File

@@ -0,0 +1,12 @@
// !LANGUAGE: +InlineClasses
inline class Z(val x: Int) {
fun foo() {}
}
fun testZ(z: Z) = z.foo()
fun testNZ(z: Z?) = z?.foo()
// 0 INVOKESTATIC Z\$Erased\.foo
// 0 INVOKESTATIC Z\-Erased\.foo
// 2 INVOKESTATIC Z\.foo \(I\)V

View File

@@ -0,0 +1,20 @@
// !LANGUAGE: +InlineClasses
// FILE: Z.kt
interface IFoo {
fun foo()
}
inline class Z(val x: Int) : IFoo {
override fun foo() {}
}
// FILE: test.kt
fun testZ(z: Z) = z.foo()
fun testNZ(z: Z?) = z?.foo()
// @TestKt.class:
// 0 INVOKESTATIC Z\$Erased\.foo
// 0 INVOKESTATIC Z\-Erased\.foo
// 2 INVOKESTATIC Z\.foo \(I\)V

View File

@@ -0,0 +1,13 @@
// !LANGUAGE: +InlineClasses
// FILE: Z.kt
inline class Z(val x: Int)
// FILE: test.kt
fun testZ(z: Z) = z.toString()
fun testNZ(z: Z?) = z?.toString()
// @TestKt.class:
// 0 INVOKESTATIC Z\$Erased\.toString
// 0 INVOKESTATIC Z\-Erased\.toString
// 2 INVOKESTATIC Z\.toString \(I\)Ljava/lang/String;