Report an error on native declarations marked ilnine
This commit is contained in:
+1
@@ -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_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_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_IN_TRAIT, "Members of traits can not be native");
|
||||||
|
MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_INLINED, "Members of traits can not be inlined");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
@@ -40,6 +40,7 @@ public interface ErrorsJvm {
|
|||||||
DiagnosticFactory0<JetDeclaration> NATIVE_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
DiagnosticFactory0<JetDeclaration> NATIVE_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
||||||
DiagnosticFactory0<JetDeclaration> NATIVE_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
DiagnosticFactory0<JetDeclaration> NATIVE_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||||
DiagnosticFactory0<JetDeclaration> NATIVE_DECLARATION_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
DiagnosticFactory0<JetDeclaration> NATIVE_DECLARATION_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||||
|
DiagnosticFactory0<JetDeclaration> NATIVE_DECLARATION_CANNOT_BE_INLINED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||||
|
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
Object _initializer = new Object() {
|
Object _initializer = new Object() {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
|||||||
import org.jetbrains.jet.lang.descriptors.Modality
|
import org.jetbrains.jet.lang.descriptors.Modality
|
||||||
import org.jetbrains.jet.lang.resolve.java.diagnostics.ErrorsJvm
|
import org.jetbrains.jet.lang.resolve.java.diagnostics.ErrorsJvm
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
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")
|
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))
|
diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY.on(declaration))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (descriptor.hasInlineAnnotation()) {
|
||||||
|
diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_INLINED.on(declaration))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import kotlin.jvm.*
|
||||||
|
|
||||||
|
abstract class C {
|
||||||
|
<!NATIVE_DECLARATION_CANNOT_BE_INLINED, NOTHING_TO_INLINE!>inline native fun foo()<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
abstract class Local {
|
||||||
|
<!NATIVE_DECLARATION_CANNOT_BE_INLINED, NOTHING_TO_INLINE!>inline native fun foo()<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import kotlin.jvm.*
|
||||||
|
|
||||||
|
native fun <<!REIFIED_TYPE_PARAMETER_NO_INLINE!>reified<!> T> foo()
|
||||||
|
<!NATIVE_DECLARATION_CANNOT_BE_INLINED!>inline native fun <reified T> bar()<!>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.inline() kotlin.jvm.native() internal fun </*0*/ reified T> bar(): kotlin.Unit
|
||||||
|
kotlin.jvm.native() internal fun </*0*/ reified T> foo(): kotlin.Unit
|
||||||
@@ -668,6 +668,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("noBody.kt")
|
||||||
public void testNoBody() throws Exception {
|
public void testNoBody() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/noBody.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/noBody.kt");
|
||||||
@@ -680,6 +686,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("trait.kt")
|
||||||
public void testTrait() throws Exception {
|
public void testTrait() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/trait.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/native/trait.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user