diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/DefaultErrorMessagesJvm.java index afbde8ced41..4b5fb7d4a18 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/DefaultErrorMessagesJvm.java @@ -50,6 +50,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { 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 traits can not be native"); + MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_INLINED, "Members of traits can not be inlined"); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/ErrorsJvm.java index 396a5d5f38e..862331fdc9e 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/diagnostics/ErrorsJvm.java @@ -40,6 +40,7 @@ public interface ErrorsJvm { 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); @SuppressWarnings("UnusedDeclaration") Object _initializer = new Object() { diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/native.kt b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/native.kt index e86111d5b7e..0c6c37dbf22 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/native.kt +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/native.kt @@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor import org.jetbrains.jet.lang.descriptors.Modality import org.jetbrains.jet.lang.resolve.java.diagnostics.ErrorsJvm import org.jetbrains.jet.lang.psi.JetDeclarationWithBody +import org.jetbrains.jet.lang.resolve.annotations.hasInlineAnnotation private val NATIVE_ANNOTATION_CLASS_NAME = FqName("kotlin.jvm.native") @@ -67,5 +68,9 @@ public class NativeFunChecker : AnnotationChecker { diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY.on(declaration)) } + if (descriptor.hasInlineAnnotation()) { + diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_INLINED.on(declaration)) + } + } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/inline.kt b/compiler/testData/diagnostics/testsWithStdLib/native/inline.kt new file mode 100644 index 00000000000..18b7793c06a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/native/inline.kt @@ -0,0 +1,11 @@ +import kotlin.jvm.* + +abstract class C { + inline native fun foo() +} + +fun test() { + abstract class Local { + inline native 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 new file mode 100644 index 00000000000..e23a11cdda2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/native/inline.txt @@ -0,0 +1,11 @@ +package + +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 + 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 new file mode 100644 index 00000000000..b65312aa4cc --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/native/reified.kt @@ -0,0 +1,4 @@ +import kotlin.jvm.* + +native fun <reified T> foo() +inline native 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 new file mode 100644 index 00000000000..221d2ff25ff --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/native/reified.txt @@ -0,0 +1,4 @@ +package + +kotlin.inline() kotlin.jvm.native() internal fun bar(): kotlin.Unit +kotlin.jvm.native() internal fun foo(): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java index 541ce38cdba..9fc7e0ceb85 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -668,6 +668,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic doTest(fileName); } + @TestMetadata("inline.kt") + public void testInline() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/inline.kt"); + doTest(fileName); + } + @TestMetadata("noBody.kt") public void testNoBody() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/noBody.kt"); @@ -680,6 +686,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic doTest(fileName); } + @TestMetadata("reified.kt") + public void testReified() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/reified.kt"); + doTest(fileName); + } + @TestMetadata("trait.kt") public void testTrait() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/trait.kt");