Support cross-module usages of @JvmRecord classes

The problem is that JvmRecord has SOURCE retention
Probably, increasing its retention might be a more reliable solution
(or in some other way serializing that the class is a record)

Just checking supertypes seems like a reasonable approximation:
only records kotlin are allowed to extend j.l.Record.
But the relevant diagnostic has been added only since 1.4.30,
so potentially there could have been exist a non-record class with
such supertype compiled by 1.4.20, but this case seems to be ill-formed
and marginal anyway.

For Java classes, it's irrelevant since they don't have member properties
(only synthetic extensions)

^KT-43677 In Progress
This commit is contained in:
Denis.Zharkov
2020-12-03 17:59:14 +03:00
parent ac0604377d
commit dc1a1c5821
10 changed files with 156 additions and 8 deletions
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
abstract class AbstractCompileKotlinAgainstKotlinJdk15Test : AbstractCompileKotlinAgainstKotlinTest() {
override fun invokeBox(className: String) {
runJvmInstance(
KotlinTestUtils.getJdk15Home(),
additionalArgs = listOf("--enable-preview"),
classPath = listOfNotNull(
aDir, bDir, ForTestCompileRuntime.runtimeJarForTests(),
),
className
)
}
override fun getTestJdkKind(files: List<TestFile>): TestJdkKind {
return TestJdkKind.FULL_JDK_15
}
}
@@ -35,8 +35,8 @@ import java.util.stream.Collectors;
public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTestCase {
private File tmpdir;
private File aDir;
private File bDir;
protected File aDir;
protected File bDir;
@Override
protected void setUp() throws Exception {
@@ -80,7 +80,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
return new Pair<>(factoryA, factoryB);
}
private void invokeBox(@NotNull String className) throws Exception {
protected void invokeBox(@NotNull String className) throws Exception {
callBoxMethodAndCheckResult(createGeneratedClassLoader(), className);
}
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.test.TargetBackend
abstract class AbstractIrCompileKotlinAgainstKotlinJdk15Test : AbstractCompileKotlinAgainstKotlinJdk15Test() {
override fun getBackendA(): TargetBackend {
return TargetBackend.JVM_IR
}
override fun getBackendB(): TargetBackend {
return TargetBackend.JVM_IR
}
}