Consider property external if all accessors are external #KT-13997 Fixed

This commit is contained in:
Mikhail Glukhikh
2017-04-28 13:12:56 +03:00
parent b8af0f5922
commit e53c548ead
4 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
// See KT-13997
class Foo {
var bar: Int // Ok
external get
external set
}
class Bar {
val foo: Int // Ok
external get
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var baz: Int<!>
external get
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var gav: Int<!>
external set
}

View File

@@ -0,0 +1,19 @@
package
public final class Bar {
public constructor Bar()
public final var baz: kotlin.Int
public final val foo: kotlin.Int
public final var gav: 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 final class Foo {
public constructor Foo()
public final var bar: 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
}

View File

@@ -254,6 +254,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("ExternalAccessors.kt")
public void testExternalAccessors() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/ExternalAccessors.kt");
doTest(fileName);
}
@TestMetadata("ExternalAndAbstract.kt")
public void testExternalAndAbstract() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/ExternalAndAbstract.kt");

View File

@@ -422,6 +422,11 @@ fun MemberDescriptor.isEffectivelyExternal(): Boolean {
if (variableDescriptor.isEffectivelyExternal()) return true
}
if (this is PropertyDescriptor) {
if (getter?.isExternal == true &&
(!isVar || setter?.isExternal == true)) return true
}
val containingClass = getContainingClass(this)
return containingClass != null && containingClass.isEffectivelyExternal()
}