JVM_IR: Lower IrGetEnumValue to this whenever possible.

The reference can be lowered to `this` if it is captured in the lexical
scope of the corresponding enum entry, and not used by the enum entry's
super constructor. Otherwise, it is lowered to
`GETFIELD SomeEnum.SomeEntry`.
This commit is contained in:
Ting-Yuan Huang
2019-04-05 17:24:40 -07:00
committed by max-kammerer
parent faa6eacb25
commit 0dd09ea7de
20 changed files with 73 additions and 34 deletions
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class A {
X {
val x = "OK"
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class A {
X {
val k = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
interface IFoo {
fun foo(): String
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
interface IFoo {
fun foo(): String
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
interface IFoo {
fun foo(): String
}
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class A {
X {
val x = "OK"
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class A {
X {
val x = "OK"
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class Test(val x: String, val closure1: () -> String) {
FOO("O", { FOO.x }) {
override val y: String = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class Test(val x: String, val closure1: () -> String) {
FOO("O", run { { FOO.x } }) {
override val y: String = "K"
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
val value2 = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
val value2 = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
val value2 = "K"
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
val k = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
override val value2 = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
override val value2 = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class X {
B {
val value2 = "K"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
fun <T, R> T.letNoInline(fn: (T) -> R) =
fn(this)