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 1f6106425b1..c8e66770559 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 @@ -47,6 +47,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and class objects of classes can be annotated with 'platformStatic'"); MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override cannot be 'platformStatic' in object"); MAP.put(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE, "This declaration does not support ''platformStatic''", DescriptorRenderer.SHORT_NAMES_IN_TYPES); + MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT, "Native declaration can not be abstract"); } 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 09f6002b39c..43b60039bd9 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 @@ -23,8 +23,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory1; import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.psi.JetDeclaration; -import static org.jetbrains.jet.lang.diagnostics.PositioningStrategies.DECLARATION_SIGNATURE; -import static org.jetbrains.jet.lang.diagnostics.PositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT; +import static org.jetbrains.jet.lang.diagnostics.PositioningStrategies.*; import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR; public interface ErrorsJvm { @@ -38,6 +37,8 @@ public interface ErrorsJvm { DiagnosticFactory0 PLATFORM_STATIC_NOT_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory1 PLATFORM_STATIC_ILLEGAL_USAGE = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE); + DiagnosticFactory0 NATIVE_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER); + @SuppressWarnings("UnusedDeclaration") Object _initializer = new Object() { { diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/JavaDeclarationCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/JavaDeclarationCheckerProvider.kt index 1d1a82a94aa..f8354af6d28 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/JavaDeclarationCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/kotlin/JavaDeclarationCheckerProvider.kt @@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.kotlin import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider import org.jetbrains.jet.lang.resolve.AnnotationChecker import org.jetbrains.jet.lang.psi.JetDeclaration -import org.jetbrains.jet.lang.descriptors.MemberDescriptor import org.jetbrains.jet.lang.resolve.annotations.hasPlatformStaticAnnotation import org.jetbrains.jet.lang.psi.JetNamedFunction import org.jetbrains.jet.lang.resolve.DescriptorUtils @@ -31,7 +30,6 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor import org.jetbrains.jet.lang.diagnostics.DiagnosticSink import org.jetbrains.jet.lang.descriptors.Visibilities import org.jetbrains.jet.lang.resolve.annotations.hasInlineAnnotation -import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor import org.jetbrains.jet.lang.descriptors.FunctionDescriptor import org.jetbrains.jet.lang.diagnostics.Errors import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor @@ -40,16 +38,13 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils import org.jetbrains.jet.lang.psi.JetTypeParameter -import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor -import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns -import org.jetbrains.jet.lang.resolve.name.Name import org.jetbrains.jet.lang.resolve.annotations.hasIntrinsicAnnotation -import org.jetbrains.jet.lang.psi.JetPropertyAccessor +import org.jetbrains.jet.lang.resolve.kotlin.nativeDeclarations.NativeFunChecker public object JavaDeclarationCheckerProvider : AdditionalCheckerProvider { override val annotationCheckers: List = listOf( - PlatformStaticAnnotationChecker(), LocalFunInlineChecker(), ReifiedTypeParameterAnnotationChecker() + PlatformStaticAnnotationChecker(), LocalFunInlineChecker(), ReifiedTypeParameterAnnotationChecker(), NativeFunChecker() ) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt b/compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt new file mode 100644 index 00000000000..ce9e34501a1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt @@ -0,0 +1,11 @@ +import kotlin.jvm.* + +abstract class C { + abstract native fun foo() +} + +fun test() { + abstract class Local { + abstract native 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 new file mode 100644 index 00000000000..244b2f5cb63 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/native/abstract.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.jvm.native() 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/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java index b53a325b393..f97e693742a 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -652,6 +652,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Native extends AbstractJetDiagnosticsTestWithStdLib { + @TestMetadata("abstract.kt") + public void testAbstract() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/abstract.kt"); + doTest(fileName); + } + public void testAllFilesPresentInNative() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/native"), Pattern.compile("^(.+)\\.kt$"), true); }