Render JVM default flags in kotlinp
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
## Next
|
||||
|
||||
- Add `JvmPropertyExtensionVisitor.visitSyntheticMethodForDelegate` for optimized delegated properties (KT-39055).
|
||||
- Add JVM-specific class flags:
|
||||
- `JvmClassExtensionVisitor.visitJvmFlags`
|
||||
- `JvmFlag.Class.HAS_METHOD_BODIES_IN_INTERFACE`
|
||||
- `JvmFlag.Class.IS_COMPILED_IN_COMPATIBILITY_MODE`
|
||||
- [`KT-48965`](https://youtrack.jetbrains.com/issue/KT-48965) Make the type of `KmValueParameter.type` non-null `KmType`
|
||||
|
||||
## 0.3.0
|
||||
|
||||
@@ -794,11 +794,16 @@ class ClassPrinter(private val settings: KotlinpSettings) : KmClassVisitor(), Ab
|
||||
return object : JvmClassExtensionVisitor() {
|
||||
private val localDelegatedProperties = mutableListOf<StringBuilder>()
|
||||
private var moduleName: String? = null
|
||||
private var jvmFlags: Flags? = null
|
||||
|
||||
override fun visitAnonymousObjectOriginName(internalName: String) {
|
||||
anonymousObjectOriginName = internalName
|
||||
}
|
||||
|
||||
override fun visitJvmFlags(flags: Flags) {
|
||||
jvmFlags = flags
|
||||
}
|
||||
|
||||
override fun visitLocalDelegatedProperty(
|
||||
flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags
|
||||
): KmPropertyVisitor? = visitProperty(
|
||||
@@ -811,6 +816,17 @@ class ClassPrinter(private val settings: KotlinpSettings) : KmClassVisitor(), Ab
|
||||
|
||||
override fun visitEnd() {
|
||||
sb.appendDeclarationContainerExtensions(settings, localDelegatedProperties, moduleName)
|
||||
val flags = jvmFlags
|
||||
if (flags != null) {
|
||||
if (JvmFlag.Class.HAS_METHOD_BODIES_IN_INTERFACE(flags)) {
|
||||
sb.appendLine()
|
||||
sb.appendLine(" // has method bodies in interface")
|
||||
}
|
||||
if (JvmFlag.Class.IS_COMPILED_IN_COMPATIBILITY_MODE(flags)) {
|
||||
sb.appendLine()
|
||||
sb.appendLine(" // is compiled in compatibility mode")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
@@ -118,4 +118,27 @@ public class KotlinpTestGenerated extends AbstractKotlinpTest {
|
||||
public void testVersionRequirement() throws Exception {
|
||||
runTest("libraries/tools/kotlinp/testData/VersionRequirement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("libraries/tools/kotlinp/testData/jvmDefault")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JvmDefault extends AbstractKotlinpTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("All.kt")
|
||||
public void testAll() throws Exception {
|
||||
runTest("libraries/tools/kotlinp/testData/jvmDefault/All.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AllCompatibility.kt")
|
||||
public void testAllCompatibility() throws Exception {
|
||||
runTest("libraries/tools/kotlinp/testData/jvmDefault/AllCompatibility.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJvmDefault() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("libraries/tools/kotlinp/testData/jvmDefault"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
|
||||
interface A {
|
||||
fun f() {}
|
||||
fun g()
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
override fun g() {}
|
||||
}
|
||||
|
||||
class C : B
|
||||
@@ -0,0 +1,40 @@
|
||||
// A.class
|
||||
// ------------------------------------------
|
||||
// requires compiler version 1.4.0 (level=ERROR)
|
||||
public abstract interface A : kotlin/Any {
|
||||
|
||||
// signature: f()V
|
||||
public open fun f(): kotlin/Unit
|
||||
|
||||
// signature: g()V
|
||||
public abstract fun g(): kotlin/Unit
|
||||
|
||||
// module name: test-module
|
||||
|
||||
// has method bodies in interface
|
||||
}
|
||||
// B.class
|
||||
// ------------------------------------------
|
||||
// requires compiler version 1.4.0 (level=ERROR)
|
||||
public abstract interface B : A {
|
||||
|
||||
// signature: g()V
|
||||
public open fun g(): kotlin/Unit
|
||||
|
||||
// module name: test-module
|
||||
|
||||
// has method bodies in interface
|
||||
}
|
||||
// C.class
|
||||
// ------------------------------------------
|
||||
public final class C : B {
|
||||
|
||||
// signature: <init>()V
|
||||
public constructor()
|
||||
|
||||
// module name: test-module
|
||||
}
|
||||
// META-INF/test-module.kotlin_module
|
||||
// ------------------------------------------
|
||||
module {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
|
||||
interface A {
|
||||
fun f() {}
|
||||
fun g()
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
override fun g() {}
|
||||
}
|
||||
|
||||
class C : B
|
||||
@@ -0,0 +1,48 @@
|
||||
// A.class
|
||||
// ------------------------------------------
|
||||
public abstract interface A : kotlin/Any {
|
||||
|
||||
// signature: f()V
|
||||
public open fun f(): kotlin/Unit
|
||||
|
||||
// signature: g()V
|
||||
public abstract fun g(): kotlin/Unit
|
||||
|
||||
// module name: test-module
|
||||
|
||||
// has method bodies in interface
|
||||
|
||||
// is compiled in compatibility mode
|
||||
}
|
||||
// A$DefaultImpls.class
|
||||
// ------------------------------------------
|
||||
synthetic class
|
||||
// B.class
|
||||
// ------------------------------------------
|
||||
public abstract interface B : A {
|
||||
|
||||
// signature: g()V
|
||||
public open fun g(): kotlin/Unit
|
||||
|
||||
// module name: test-module
|
||||
|
||||
// has method bodies in interface
|
||||
|
||||
// is compiled in compatibility mode
|
||||
}
|
||||
// B$DefaultImpls.class
|
||||
// ------------------------------------------
|
||||
synthetic class
|
||||
// C.class
|
||||
// ------------------------------------------
|
||||
public final class C : B {
|
||||
|
||||
// signature: <init>()V
|
||||
public constructor()
|
||||
|
||||
// module name: test-module
|
||||
}
|
||||
// META-INF/test-module.kotlin_module
|
||||
// ------------------------------------------
|
||||
module {
|
||||
}
|
||||
Reference in New Issue
Block a user