JVM_IR KT-45967 generate accessor for argument of indy intrinsic

TODO handle inaccessible constructors gracefully
This commit is contained in:
Dmitry Petrov
2021-04-09 17:16:30 +03:00
committed by TeamCityServer
parent 5f9fe8e5de
commit f59b49db68
16 changed files with 523 additions and 82 deletions
@@ -0,0 +1,25 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FILE: privateBoundOuterClassMemberFun.kt
interface GetStep {
fun get(): Step
}
class Outer(val k: String) {
fun gs(x: Outer) =
object : GetStep {
override fun get(): Step = Step(x::test)
}
private fun test(s: String) = s + k
}
fun box(): String =
Outer("!").gs(Outer("K")).get().step("O")
// FILE: Step.java
public interface Step {
String step(String string);
}
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FILE: privateCompanionObjectMember.kt
class StepProcessor {
fun build() = Step(::test)
companion object {
private fun test(string: String): String = string
}
}
fun box(): String =
StepProcessor().build().step("OK")
// FILE: Step.java
public interface Step {
String step(String string);
}
@@ -0,0 +1,35 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FILE: privateOuterClassConstructor.kt
interface GetStep {
fun get(): Step
}
class Outer {
private val ok: String
private constructor(ok: String) {
this.ok = ok
}
constructor() {
this.ok = "xxx"
}
val obj = object : GetStep {
override fun get(): Step = Step(::Outer)
}
override fun toString() = ok
}
fun box() =
Outer().obj.get().step("OK").toString()
// FILE: Step.java
public interface Step {
Object step(String string);
}
@@ -0,0 +1,24 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FILE: privateOuterClassMemberFun.kt
interface GetStep {
fun get(): Step
}
class Outer(val k: String) {
val obj = object : GetStep {
override fun get(): Step = Step(::test)
}
private fun test(s: String) = s + k
}
fun box(): String =
Outer("K").obj.get().step("O")
// FILE: Step.java
public interface Step {
String step(String string);
}
@@ -0,0 +1,19 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FILE: privateTopLevelExtFun.kt
class StepProcessor {
fun build() = Step("O"::test)
}
private fun String.test(string: String): String =
this + string
fun box(): String =
StepProcessor().build().step("K")
// FILE: Step.java
public interface Step {
String step(String string);
}
@@ -0,0 +1,18 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FILE: privateTopLevelFun.kt
class StepProcessor {
fun build() = Step(::test)
}
private fun test(string: String): String = string
fun box(): String =
StepProcessor().build().step("OK")
// FILE: Step.java
public interface Step {
String step(String string);
}