Effective visibility: fix for internal & protected vs protected comparison #KT-9582 Fixed
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
public open class A {
|
||||||
|
protected open class B
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class C : A() {
|
||||||
|
protected open class D {
|
||||||
|
// internal & protected(in C) <= protected(in A): Ok
|
||||||
|
internal open class E : A.B()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public open class A {
|
||||||
|
public constructor A()
|
||||||
|
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
|
||||||
|
|
||||||
|
protected open class B {
|
||||||
|
public constructor B()
|
||||||
|
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 open class C : A {
|
||||||
|
public constructor C()
|
||||||
|
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
|
||||||
|
|
||||||
|
protected open class D {
|
||||||
|
public constructor D()
|
||||||
|
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
|
||||||
|
|
||||||
|
internal open class E : A.B {
|
||||||
|
public constructor E()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5802,6 +5802,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalAndProtected.kt")
|
||||||
|
public void testInternalAndProtected() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/internalAndProtected.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("local.kt")
|
@TestMetadata("local.kt")
|
||||||
public void testLocal() throws Exception {
|
public void testLocal() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/local.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/local.kt");
|
||||||
|
|||||||
@@ -75,8 +75,9 @@ sealed class EffectiveVisibility(val name: String) {
|
|||||||
Private, ProtectedBound, InternalProtectedBound -> Permissiveness.MORE
|
Private, ProtectedBound, InternalProtectedBound -> Permissiveness.MORE
|
||||||
is Protected -> containerRelation(container, other.container)
|
is Protected -> containerRelation(container, other.container)
|
||||||
is InternalProtected -> when (containerRelation(container, other.container)) {
|
is InternalProtected -> when (containerRelation(container, other.container)) {
|
||||||
Permissiveness.SAME, Permissiveness.LESS -> Permissiveness.LESS
|
// Protected never can be less permissive than internal & protected
|
||||||
Permissiveness.UNKNOWN, Permissiveness.MORE -> Permissiveness.UNKNOWN
|
Permissiveness.SAME, Permissiveness.MORE -> Permissiveness.MORE
|
||||||
|
Permissiveness.UNKNOWN, Permissiveness.LESS -> Permissiveness.UNKNOWN
|
||||||
}
|
}
|
||||||
Internal -> Permissiveness.UNKNOWN
|
Internal -> Permissiveness.UNKNOWN
|
||||||
}
|
}
|
||||||
@@ -127,8 +128,9 @@ sealed class EffectiveVisibility(val name: String) {
|
|||||||
Private, InternalProtectedBound -> Permissiveness.MORE
|
Private, InternalProtectedBound -> Permissiveness.MORE
|
||||||
is InternalProtected -> containerRelation(container, other.container)
|
is InternalProtected -> containerRelation(container, other.container)
|
||||||
is Protected -> when (containerRelation(container, other.container)) {
|
is Protected -> when (containerRelation(container, other.container)) {
|
||||||
Permissiveness.SAME, Permissiveness.MORE -> Permissiveness.MORE
|
// Internal & protected never can be more permissive than just protected
|
||||||
Permissiveness.UNKNOWN, Permissiveness.LESS -> Permissiveness.UNKNOWN
|
Permissiveness.SAME, Permissiveness.LESS -> Permissiveness.LESS
|
||||||
|
Permissiveness.UNKNOWN, Permissiveness.MORE -> Permissiveness.UNKNOWN
|
||||||
}
|
}
|
||||||
ProtectedBound -> Permissiveness.UNKNOWN
|
ProtectedBound -> Permissiveness.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user