Support fun interfaces in kotlinx-metadata

#KT-37421 Fixed
This commit is contained in:
Alexander Udalov
2020-05-12 20:35:26 +02:00
parent c805274d2e
commit 4520e02bae
16 changed files with 78 additions and 1 deletions
@@ -0,0 +1,4 @@
public abstract interface F : R|kotlin/Any| {
public abstract fun R|kotlin/String|.f(x: R|kotlin/Int|): R|kotlin/Unit|
}
@@ -604,6 +604,11 @@ public class FirLoadCompiledKotlinGenerated extends AbstractFirLoadCompiledKotli
runTest("compiler/testData/loadJava/compiledKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
}
@TestMetadata("FunInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/FunInterface.kt");
}
@TestMetadata("InheritClassSimple.kt")
public void testInheritClassSimple() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/InheritClassSimple.kt");
@@ -0,0 +1,5 @@
package test
fun interface F {
fun String.f(x: Int)
}
@@ -0,0 +1,5 @@
package test
public fun interface F {
public abstract fun kotlin.String.f(/*0*/ x: kotlin.Int): kotlin.Unit
}
@@ -2295,6 +2295,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
runTest("compiler/testData/loadJava/compiledKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
}
@TestMetadata("FunInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/FunInterface.kt");
}
@TestMetadata("InheritClassSimple.kt")
public void testInheritClassSimple() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/InheritClassSimple.kt");
@@ -604,6 +604,11 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith
runTest("compiler/testData/loadJava/compiledKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
}
@TestMetadata("FunInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/FunInterface.kt");
}
@TestMetadata("InheritClassSimple.kt")
public void testInheritClassSimple() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/InheritClassSimple.kt");
@@ -2296,6 +2296,11 @@ public class IrLoadJavaTestGenerated extends AbstractIrLoadJavaTest {
runTest("compiler/testData/loadJava/compiledKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
}
@TestMetadata("FunInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/FunInterface.kt");
}
@TestMetadata("InheritClassSimple.kt")
public void testInheritClassSimple() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/InheritClassSimple.kt");
@@ -2295,6 +2295,11 @@ public class LoadJavaUsingJavacTestGenerated extends AbstractLoadJavaUsingJavacT
runTest("compiler/testData/loadJava/compiledKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
}
@TestMetadata("FunInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/FunInterface.kt");
}
@TestMetadata("InheritClassSimple.kt")
public void testInheritClassSimple() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/InheritClassSimple.kt");
@@ -606,6 +606,11 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
runTest("compiler/testData/loadJava/compiledKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
}
@TestMetadata("FunInterface.kt")
public void testFunInterface() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/FunInterface.kt");
}
@TestMetadata("InheritClassSimple.kt")
public void testInheritClassSimple() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/class/InheritClassSimple.kt");
@@ -1,5 +1,10 @@
# kotlinx-metadata-jvm
## 0.1.1
- [`KT-37421`](https://youtrack.jetbrains.com/issue/KT-37421) Add Flag.Class.IS_FUN for functional interfaces
- Add `KmModule.optionalAnnotationClasses` for the new scheme of compilation of OptionalExpectation annotations in multiplatform projects ([KT-38652](https://youtrack.jetbrains.com/issue/KT-38652))
## 0.1.0
- [`KT-26602`](https://youtrack.jetbrains.com/issue/KT-26602) Provide a value-based API
@@ -207,6 +207,12 @@ class Flag(private val offset: Int, private val bitWidth: Int, private val value
*/
@JvmField
val IS_INLINE = Flag(F.IS_INLINE_CLASS)
/**
* Signifies that the corresponding class is a functional interface, i.e. marked with the keyword `fun`.
*/
@JvmField
val IS_FUN = Flag(F.IS_FUN_INTERFACE)
}
/**
@@ -946,6 +946,7 @@ private val CLASS_FLAGS_MAP = COMMON_FLAGS_MAP + mapOf(
Flag.Class.IS_EXTERNAL to "external",
Flag.Class.IS_EXPECT to "expect",
Flag.Class.IS_INLINE to "inline",
Flag.Class.IS_FUN to "fun",
Flag.Class.IS_CLASS to "class",
Flag.Class.IS_INTERFACE to "interface",
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.kotlinp.test
import org.jetbrains.kotlin.generators.tests.generator.testGroup
fun main(args: Array<String>) {
fun main() {
System.setProperty("java.awt.headless", "true")
testGroup("libraries/tools/kotlinp/test", "libraries/tools/kotlinp/testData") {
@@ -38,6 +38,11 @@ public class KotlinpTestGenerated extends AbstractKotlinpTest {
runTest("libraries/tools/kotlinp/testData/Contracts.kt");
}
@TestMetadata("FunInterface.kt")
public void testFunInterface() throws Exception {
runTest("libraries/tools/kotlinp/testData/FunInterface.kt");
}
@TestMetadata("Lambda.kt")
public void testLambda() throws Exception {
runTest("libraries/tools/kotlinp/testData/Lambda.kt");
+3
View File
@@ -0,0 +1,3 @@
fun interface F {
fun String.f(x: Int)
}
+13
View File
@@ -0,0 +1,13 @@
// F.class
// ------------------------------------------
public abstract fun interface F : kotlin/Any {
// signature: f(Ljava/lang/String;I)V
public abstract fun kotlin/String.f(x: kotlin/Int): kotlin/Unit
// module name: test-module
}
// META-INF/test-module.kotlin_module
// ------------------------------------------
module {
}