mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-18 08:31:38 +00:00
JVM_IR: KT-40330 Unify field names for captured 'this' with JVM
NB some cases such as captured extension receiver for an extension lambda are not supported yet; to be discussed, to what extent should we actually follow JVM code shape here.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
class Receiver {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun useExtensionLambda(lambda: Receiver.() -> Unit) {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
useExtensionLambda {
|
||||
class NamedLocal {
|
||||
fun run() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LReceiver; \$this_useExtensionLambda
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LReceiver; \$this
|
||||
17
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/extensionReceiver.kt
vendored
Normal file
17
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/extensionReceiver.kt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
class Receiver {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun Receiver.bar() {
|
||||
class NamedLocal {
|
||||
fun run() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LReceiver; \$this_bar
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LReceiver; \$this_bar
|
||||
23
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/innerAndOuterThis.kt
vendored
Normal file
23
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/innerAndOuterThis.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
class Outer {
|
||||
inner class Inner {
|
||||
private fun bar() {
|
||||
class NamedLocal {
|
||||
fun run() {
|
||||
innerFoo()
|
||||
outerFoo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun innerFoo() {}
|
||||
}
|
||||
|
||||
fun outerFoo() {}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LOuter\$Inner; this\$0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LOuter\$Inner; this\$0
|
||||
// 1 private final synthetic LOuter; this\$1
|
||||
@@ -0,0 +1,22 @@
|
||||
class Receiver {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun useExtensionLambda(lambda: Receiver.() -> Unit) {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
useExtensionLambda label@ {
|
||||
class NamedLocal {
|
||||
fun run() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LReceiver; \$this_label
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LReceiver; \$this
|
||||
26
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/multipleExtensionReceivers.kt
vendored
Normal file
26
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/multipleExtensionReceivers.kt
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
class Foo {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun Foo.test(bar: Bar) {
|
||||
fun Bar.test() {
|
||||
class Local {
|
||||
fun run() {
|
||||
foo()
|
||||
bar()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LMultipleExtensionReceiversKt\$test\$1; this\$0
|
||||
// 1 final synthetic LBar; \$this_test
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LFoo; \$this_test
|
||||
// 1 private final synthetic LBar; \$this_test\$1
|
||||
19
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/outerThis.kt
vendored
Normal file
19
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/outerThis.kt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
class Outer {
|
||||
inner class Inner {
|
||||
private fun bar() {
|
||||
class NamedLocal {
|
||||
fun run() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LOuter\$Inner; this\$0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LOuter; this\$0
|
||||
19
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/outerThisInInnerConstructor.kt
vendored
Normal file
19
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/outerThisInInnerConstructor.kt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
class Outer {
|
||||
inner class Inner {
|
||||
constructor() {
|
||||
class NamedLocal {
|
||||
fun foo() {
|
||||
outer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun outer() {}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LOuter\$Inner; this\$0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LOuter; this\$0
|
||||
19
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/outerThisInInnerInitBlock.kt
vendored
Normal file
19
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/outerThisInInnerInitBlock.kt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
class Outer {
|
||||
inner class Inner {
|
||||
init {
|
||||
class NamedLocal {
|
||||
fun foo() {
|
||||
outer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun outer() {}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LOuter\$Inner; this\$0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LOuter; this\$0
|
||||
17
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/this.kt
vendored
Normal file
17
compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/this.kt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
class Host {
|
||||
private fun bar() {
|
||||
class NamedLocal {
|
||||
fun run() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 final synthetic LHost; this\$0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 private final synthetic LHost; this\$0
|
||||
Reference in New Issue
Block a user