Generate reference to existing class for builtin function references

Instead of non-existing `kotlin.KotlinPackage`, which led to
NoClassDefFoundError as soon as reflection tried to call getOwner on a
builtin callable reference, use a reference to a new physical class
`kotlin.jvm.internal.Intrinsics$Kotlin`. This will allow to support
KT-17151.

Note that for API version less than 1.4, this will still lead to
NoClassDefFoundError, but this is not worse than the current situation
where it happens anyway.
This commit is contained in:
Alexander Udalov
2020-02-25 18:08:02 +01:00
parent bfa371ea73
commit 8d7c8672ac
10 changed files with 65 additions and 6 deletions
@@ -1983,6 +1983,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("builtinFunctionReferenceOwner.kt")
public void testBuiltinFunctionReferenceOwner() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/builtinFunctionReferenceOwner.kt");
}
@TestMetadata("classesAreSynthetic.kt")
public void testClassesAreSynthetic() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");