diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index 257ffde7f18..42257451015 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -67,7 +67,8 @@ public abstract class AnnotationCodegen { public static final List METHOD_FLAGS = Arrays.asList( new JvmFlagAnnotation("kotlin.jvm.Strictfp", Opcodes.ACC_STRICT), new JvmFlagAnnotation("kotlin.jvm.Synchronized", Opcodes.ACC_SYNCHRONIZED), - new JvmFlagAnnotation("kotlin.jvm.native", Opcodes.ACC_NATIVE) + new JvmFlagAnnotation("kotlin.jvm.native", Opcodes.ACC_NATIVE), + new JvmFlagAnnotation("kotlin.external", Opcodes.ACC_NATIVE) ); private static final AnnotationVisitor NO_ANNOTATION_VISITOR = new AnnotationVisitor(Opcodes.ASM5) {}; diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt index 61683812fc5..aa6f3adf05c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt @@ -34,11 +34,15 @@ import org.jetbrains.kotlin.resolve.diagnostics.SuppressDiagnosticsByAnnotations import org.jetbrains.kotlin.resolve.diagnostics.FUNCTION_NO_BODY_ERRORS private val NATIVE_ANNOTATION_CLASS_NAME = FqName("kotlin.jvm.native") +private val EXTERNAL_ANNOTATION_CLASS_NAME = FqName("kotlin.external") + public fun DeclarationDescriptor.hasNativeAnnotation(): Boolean { - return getAnnotations().findAnnotation(NATIVE_ANNOTATION_CLASS_NAME) != null + return getAnnotations().findAnnotation(EXTERNAL_ANNOTATION_CLASS_NAME) != null + || annotations.findAnnotation(NATIVE_ANNOTATION_CLASS_NAME) != null } +public class SuppressNoBodyErrorsForExternalDeclarations : SuppressDiagnosticsByAnnotations(FUNCTION_NO_BODY_ERRORS, EXTERNAL_ANNOTATION_CLASS_NAME) public class SuppressNoBodyErrorsForNativeDeclarations : SuppressDiagnosticsByAnnotations(FUNCTION_NO_BODY_ERRORS, NATIVE_ANNOTATION_CLASS_NAME) public class NativeFunChecker : DeclarationChecker { @@ -51,19 +55,19 @@ public class NativeFunChecker : DeclarationChecker { if (!descriptor.hasNativeAnnotation()) return if (DescriptorUtils.isTrait(descriptor.getContainingDeclaration())) { - diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_IN_TRAIT.on(declaration)) + diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_IN_TRAIT.on(declaration)) } else if (descriptor is CallableMemberDescriptor && descriptor.getModality() == Modality.ABSTRACT) { - diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration)) + diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration)) } if (descriptor !is ConstructorDescriptor && declaration is JetDeclarationWithBody && declaration.hasBody()) { - diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY.on(declaration)) + diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY.on(declaration)) } if (descriptor.hasInlineAnnotation()) { - diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_INLINED.on(declaration)) + diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_INLINED.on(declaration)) } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 16f4e589ee8..2369229e199 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -54,10 +54,10 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "''jvmOverloads'' annotation has no effect on private and local declarations"); MAP.put(ErrorsJvm.INAPPLICABLE_JVM_NAME, "''jvmName'' annotation is not applicable to this declaration"); MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name: ''{0}''", STRING); - MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT, "Native declaration can not be abstract"); - MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY, "Native declaration can not have a body"); - MAP.put(ErrorsJvm.NATIVE_DECLARATION_IN_TRAIT, "Members of interfaces can not be native"); - MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_INLINED, "Members of interfaces can not be inlined"); + MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract"); + MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body"); + MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_IN_TRAIT, "Members of interfaces can not be external"); + MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_INLINED, "Members of interfaces can not be external"); MAP.put(ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, "Only named arguments are available for Java annotations"); MAP.put(ErrorsJvm.DEPRECATED_ANNOTATION_METHOD_CALL, "Annotation methods are deprecated. Use property instead"); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 9481e3f2b70..59f049a63ed 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -50,10 +50,10 @@ public interface ErrorsJvm { DiagnosticFactory0 OVERLOADS_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 OVERLOADS_PRIVATE = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE); - DiagnosticFactory0 NATIVE_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER); - DiagnosticFactory0 NATIVE_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); - DiagnosticFactory0 NATIVE_DECLARATION_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); - DiagnosticFactory0 NATIVE_DECLARATION_CANNOT_BE_INLINED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); + DiagnosticFactory0 EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER); + DiagnosticFactory0 EXTERNAL_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); + DiagnosticFactory0 EXTERNAL_DECLARATION_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); + DiagnosticFactory0 EXTERNAL_DECLARATION_CANNOT_BE_INLINED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 DEPRECATED_ANNOTATION_METHOD_CALL = DiagnosticFactory0.create(WARNING); diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/default.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/default.kt index 3ca8bc4b791..65824bb7092 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/default.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/default.kt @@ -4,12 +4,12 @@ import kotlin.jvm.* import kotlin.platform.* object ObjWithNative { - native fun foo(x: Int = 1): Double + external fun foo(x: Int = 1): Double - platformStatic native fun bar(l: Long, s: String = ""): Double + platformStatic external fun bar(l: Long, s: String = ""): Double } -native fun topLevel(x: Int = 1): Double +external fun topLevel(x: Int = 1): Double fun box(): String { var d = 0.0 diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/nativePropertyAccessors.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/nativePropertyAccessors.kt index bff18f98f14..8ddcc713912 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/nativePropertyAccessors.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/nativePropertyAccessors.kt @@ -1,27 +1,27 @@ class C { companion object { val defaultGetter: Int = 1 - @native get + @external get var defaultSetter: Int = 1 - @native get - @native set + @external get + @external set } val defaultGetter: Int = 1 - @native get + @external get var defaultSetter: Int = 1 - @native get - @native set + @external get + @external set } val defaultGetter: Int = 1 - @native get + @external get var defaultSetter: Int = 1 - @native get - @native set + @external get + @external set fun check(body: () -> Unit, signature: String): String? { try { diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/privateStatic.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/privateStatic.kt index d3b119824e5..5cfb2b880ff 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/privateStatic.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/privateStatic.kt @@ -3,7 +3,7 @@ import kotlin.platform.* class C { companion object { - private platformStatic native fun foo() + private platformStatic external fun foo() } fun bar() { diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/simpleNative.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/simpleNative.kt index e928c3d6506..f9bb6af036b 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/simpleNative.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/simpleNative.kt @@ -3,7 +3,7 @@ package foo import kotlin.jvm.* class WithNative { - native fun foo() + external fun foo() } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/staticNative.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/staticNative.kt index e013f14db60..2d1d4bd15d8 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/staticNative.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/staticNative.kt @@ -5,12 +5,12 @@ import kotlin.platform.* class WithNative { companion object { - platformStatic native fun bar(l: Long, s: String): Double + platformStatic external fun bar(l: Long, s: String): Double } } object ObjWithNative { - platformStatic native fun bar(l: Long, s: String): Double + platformStatic external fun bar(l: Long, s: String): Double } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/topLevel.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/topLevel.kt index 042db8cf77b..7f16a12f9de 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/native/topLevel.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/topLevel.kt @@ -3,7 +3,7 @@ package foo import kotlin.jvm.* import kotlin.platform.* -native fun bar(l: Long, s: String): Double +external fun bar(l: Long, s: String): Double fun box(): String { var d = 0.0 diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt b/compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt index ce9e34501a1..bcf7943202d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt @@ -1,11 +1,11 @@ import kotlin.jvm.* abstract class C { - abstract native fun foo() + abstract external fun foo() } fun test() { abstract class Local { - abstract native fun foo() + abstract external fun foo() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/abstract.txt b/compiler/testData/diagnostics/testsWithStdLib/native/abstract.txt index 244b2f5cb63..ce8334d4446 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/abstract.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/abstract.txt @@ -5,7 +5,7 @@ internal fun test(): kotlin.Unit internal abstract class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal abstract fun foo(): kotlin.Unit + kotlin.external() internal abstract fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/body.kt b/compiler/testData/diagnostics/testsWithStdLib/native/body.kt index 32074626c6c..df1d978cf5d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/body.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/body.kt @@ -1,25 +1,25 @@ import kotlin.jvm.* -native fun foo() {} +external fun foo() {} class C { - native fun foo() {} + external fun foo() {} companion object { - native fun foo() {} + external fun foo() {} } } object O { - native fun foo() {} + external fun foo() {} } fun test() { class Local { - native fun foo() {} + external fun foo() {} } object { - native fun foo() {} + external fun foo() {} } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/body.txt b/compiler/testData/diagnostics/testsWithStdLib/native/body.txt index bc2c9b2c7bd..a38189d565d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/body.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/body.txt @@ -1,19 +1,19 @@ package -kotlin.jvm.native() internal fun foo(): kotlin.Unit +kotlin.external() internal fun foo(): kotlin.Unit internal fun test(): kotlin.Unit internal final class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public companion object Companion { private constructor Companion() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } @@ -22,7 +22,7 @@ internal final class C { internal object O { private constructor O() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/constructor.kt b/compiler/testData/diagnostics/testsWithStdLib/native/constructor.kt index e0f0bd9230a..4e6c6f87545 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/constructor.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/constructor.kt @@ -1,10 +1,10 @@ class A { - native constructor() {} + external constructor() {} inner class B { - native constructor() {} + external constructor() {} } - native constructor(x: Int) + external constructor(x: Int) } -class C native constructor() \ No newline at end of file +class C external constructor() \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/constructor.txt b/compiler/testData/diagnostics/testsWithStdLib/native/constructor.txt index 645634c0081..0e9d75f4d59 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/constructor.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/constructor.txt @@ -1,14 +1,14 @@ package internal final class A { - kotlin.jvm.native() public constructor A() - kotlin.jvm.native() public constructor A(/*0*/ x: kotlin.Int) + kotlin.external() public constructor A() + kotlin.external() public constructor A(/*0*/ x: kotlin.Int) public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String internal final inner class B { - kotlin.jvm.native() public constructor B() + kotlin.external() public constructor B() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -16,7 +16,7 @@ internal final class A { } internal final class C { - kotlin.jvm.native() public constructor C() + kotlin.external() public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/inline.kt b/compiler/testData/diagnostics/testsWithStdLib/native/inline.kt index 18b7793c06a..54cb0fda2be 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/inline.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/inline.kt @@ -1,11 +1,11 @@ import kotlin.jvm.* abstract class C { - inline native fun foo() + inline external fun foo() } fun test() { abstract class Local { - inline native fun foo() + inline external fun foo() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/inline.txt b/compiler/testData/diagnostics/testsWithStdLib/native/inline.txt index e23a11cdda2..61ca8c3e45d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/inline.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/inline.txt @@ -5,7 +5,7 @@ internal fun test(): kotlin.Unit internal abstract class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.inline() kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.inline() kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/noBody.kt b/compiler/testData/diagnostics/testsWithStdLib/native/noBody.kt index e7478789198..3d262f82bb0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/noBody.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/noBody.kt @@ -1,25 +1,25 @@ import kotlin.jvm.* -native fun foo() +external fun foo() class C { - native fun foo() + external fun foo() companion object { - native fun foo() + external fun foo() } } object O { - native fun foo() + external fun foo() } fun test() { class Local { - native fun foo() + external fun foo() } object { - native fun foo() + external fun foo() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/noBody.txt b/compiler/testData/diagnostics/testsWithStdLib/native/noBody.txt index bc2c9b2c7bd..a38189d565d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/noBody.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/noBody.txt @@ -1,19 +1,19 @@ package -kotlin.jvm.native() internal fun foo(): kotlin.Unit +kotlin.external() internal fun foo(): kotlin.Unit internal fun test(): kotlin.Unit internal final class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public companion object Companion { private constructor Companion() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } @@ -22,7 +22,7 @@ internal final class C { internal object O { private constructor O() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/override.kt b/compiler/testData/diagnostics/testsWithStdLib/native/override.kt index 57ab03f7b76..7662d324aa0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/override.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/override.kt @@ -5,5 +5,5 @@ interface Base { } class Derived : Base { - override native fun foo() + override external fun foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/override.txt b/compiler/testData/diagnostics/testsWithStdLib/native/override.txt index 09750bfa064..b81b1ec87d4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/override.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/override.txt @@ -10,7 +10,7 @@ internal interface Base { internal final class Derived : Base { public constructor Derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal open override /*1*/ fun foo(): kotlin.Unit + kotlin.external() internal open override /*1*/ fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/reified.kt b/compiler/testData/diagnostics/testsWithStdLib/native/reified.kt index b65312aa4cc..3950079bee9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/reified.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/reified.kt @@ -1,4 +1,4 @@ import kotlin.jvm.* -native fun <reified T> foo() -inline native fun bar() \ No newline at end of file +external fun <reified T> foo() +inline external fun bar() \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/reified.txt b/compiler/testData/diagnostics/testsWithStdLib/native/reified.txt index 221d2ff25ff..7272ab9d1fe 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/reified.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/reified.txt @@ -1,4 +1,4 @@ package -kotlin.inline() kotlin.jvm.native() internal fun bar(): kotlin.Unit -kotlin.jvm.native() internal fun foo(): kotlin.Unit +kotlin.inline() kotlin.external() internal fun bar(): kotlin.Unit +kotlin.external() internal fun foo(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/trait.kt b/compiler/testData/diagnostics/testsWithStdLib/native/trait.kt index c318b5b2350..d02af9de9c8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/trait.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/trait.kt @@ -1,11 +1,11 @@ import kotlin.jvm.* interface Tr { - native fun foo() - native fun bar() {} + external fun foo() + external fun bar() {} companion object { - native fun foo() - native fun bar() {} + external fun foo() + external fun bar() {} } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/trait.txt b/compiler/testData/diagnostics/testsWithStdLib/native/trait.txt index c8d6f7fffc3..c54a9e1b3c8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/native/trait.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/native/trait.txt @@ -1,17 +1,17 @@ package internal interface Tr { - kotlin.jvm.native() internal open fun bar(): kotlin.Unit + kotlin.external() internal open fun bar(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal abstract fun foo(): kotlin.Unit + kotlin.external() internal abstract fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public companion object Companion { private constructor Companion() - kotlin.jvm.native() internal final fun bar(): kotlin.Unit + kotlin.external() internal final fun bar(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - kotlin.jvm.native() internal final fun foo(): kotlin.Unit + kotlin.external() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/core/builtins/src/kotlin/Annotations.kt b/core/builtins/src/kotlin/Annotations.kt index 36afa713a40..80cb0fd4f09 100644 --- a/core/builtins/src/kotlin/Annotations.kt +++ b/core/builtins/src/kotlin/Annotations.kt @@ -89,3 +89,10 @@ public annotation(retention = SOURCE) class tailrec target(FUNCTION, PROPERTY, CONSTRUCTOR) annotation(retention = BINARY, mustBeDocumented = true) public class HiddenDeclaration + +/** + * Marks annotated function as `external`, meaning that it's not implemented + * in Kotlin but rather in a different language (for example, in C/C++ using JNI or JavaScript). + */ +target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER) +public annotation(retention = AnnotationRetention.SOURCE, mustBeDocumented = true) class external diff --git a/idea/src/META-INF/extensions/kotlin2jvm.xml b/idea/src/META-INF/extensions/kotlin2jvm.xml index e8364241218..03a5b069f0a 100644 --- a/idea/src/META-INF/extensions/kotlin2jvm.xml +++ b/idea/src/META-INF/extensions/kotlin2jvm.xml @@ -4,6 +4,7 @@ + diff --git a/libraries/stdlib/src/kotlin/jvm/JvmFlagAnnotations.kt b/libraries/stdlib/src/kotlin/jvm/JvmFlagAnnotations.kt index 06165b4b7d7..377573a5580 100644 --- a/libraries/stdlib/src/kotlin/jvm/JvmFlagAnnotations.kt +++ b/libraries/stdlib/src/kotlin/jvm/JvmFlagAnnotations.kt @@ -53,4 +53,5 @@ public annotation(retention = AnnotationRetention.SOURCE, mustBeDocumented = tru * in Java but rather in a different language (for example, in C/C++ using JNI). */ target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER) +@deprecated("Use kotlin.external instead", ReplaceWith("kotlin.external")) public annotation(retention = AnnotationRetention.SOURCE, mustBeDocumented = true) class native