EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT is now reported on property if accessor is external #KT-9297 Fixed

Also fixes EA-89227
This commit is contained in:
Mikhail Glukhikh
2016-10-25 16:48:38 +03:00
parent e053b77ede
commit 2130164d9b
4 changed files with 38 additions and 1 deletions
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
import org.jetbrains.kotlin.psi.KtPropertyAccessor
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.checkers.SimpleDeclarationChecker
@@ -40,7 +41,12 @@ class ExternalFunChecker : SimpleDeclarationChecker {
}
else if (descriptor is CallableMemberDescriptor &&
descriptor.modality == Modality.ABSTRACT) {
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration))
if (declaration is KtPropertyAccessor) {
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration.property))
}
else {
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration))
}
}
if (descriptor !is ConstructorDescriptor && declaration is KtDeclarationWithBody && declaration.hasBody()) {
@@ -0,0 +1,9 @@
abstract class A {
<!EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT!>abstract<!> val x : Int
external get
}
interface B {
val x: Int
<!EXTERNAL_DECLARATION_IN_INTERFACE!>external get<!>
}
@@ -0,0 +1,16 @@
package
public abstract class A {
public constructor A()
public abstract val 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
}
public interface B {
public abstract val 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
}
@@ -247,6 +247,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("ExternalAndAbstract.kt")
public void testExternalAndAbstract() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/ExternalAndAbstract.kt");
doTest(fileName);
}
@TestMetadata("fileDependencyRecursion.kt")
public void testFileDependencyRecursion() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/fileDependencyRecursion.kt");