Change class loader in ir interpreter that is used to create proxy obj
#KT-54509 Fixed
This commit is contained in:
+6
@@ -17015,6 +17015,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/evaluate/simpleCallBinary.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("thisPlusString.kt")
|
||||
public void testThisPlusString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/evaluate/thisPlusString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unaryMinus.kt")
|
||||
public void testUnaryMinus() throws Exception {
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ internal class CommonProxy private constructor(override val state: Common, overr
|
||||
else -> arrayOf(extendFrom, Proxy::class.java)
|
||||
}
|
||||
|
||||
return java.lang.reflect.Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), interfaces)
|
||||
return java.lang.reflect.Proxy.newProxyInstance(this::class.java.classLoader, interfaces)
|
||||
{ /*proxy*/_, method, args ->
|
||||
when {
|
||||
method.declaringClass == Proxy::class.java && method.name == "getState" -> commonProxy.state
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
|
||||
object Test {
|
||||
fun foo(): String = "foo " + this
|
||||
|
||||
fun bar(): String = "bar $this"
|
||||
|
||||
fun baz(): String = "baz " + this.toString()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (!Test.foo().startsWith("foo ")) return "Fail ${Test.foo()}"
|
||||
if (!Test.bar().startsWith("bar ")) return "Fail ${Test.bar()}"
|
||||
if (!Test.baz().startsWith("baz ")) return "Fail ${Test.baz()}"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
// for more information see KT-54509
|
||||
object Test {
|
||||
fun foo(): String = "foo " + this
|
||||
|
||||
fun bar(): String = "bar $this"
|
||||
|
||||
fun baz(): String = "baz " + this.toString()
|
||||
}
|
||||
|
||||
fun main() {
|
||||
println(Test.foo() + Test.bar() + Test.baz())
|
||||
}
|
||||
+6
@@ -17015,6 +17015,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/evaluate/simpleCallBinary.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("thisPlusString.kt")
|
||||
public void testThisPlusString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/evaluate/thisPlusString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unaryMinus.kt")
|
||||
public void testUnaryMinus() throws Exception {
|
||||
|
||||
@@ -472,4 +472,10 @@ println(42)
|
||||
environment = jdk11,
|
||||
)
|
||||
}
|
||||
|
||||
fun testInterpreterClassLoader() {
|
||||
runProcess(
|
||||
"kotlinc", "$testDataDirectory/interpreterClassLoader.kt", "-d", tmpdir.path
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user