private members of traits are not open by default
#KT-4171 Fixed
This commit is contained in:
@@ -327,12 +327,12 @@ public class DescriptorResolver {
|
|||||||
return defaultVisibility;
|
return defaultVisibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Modality getDefaultModality(DeclarationDescriptor containingDescriptor, boolean isBodyPresent) {
|
public static Modality getDefaultModality(DeclarationDescriptor containingDescriptor, Visibility visibility, boolean isBodyPresent) {
|
||||||
Modality defaultModality;
|
Modality defaultModality;
|
||||||
if (containingDescriptor instanceof ClassDescriptor) {
|
if (containingDescriptor instanceof ClassDescriptor) {
|
||||||
boolean isTrait = ((ClassDescriptor) containingDescriptor).getKind() == ClassKind.TRAIT;
|
boolean isTrait = ((ClassDescriptor) containingDescriptor).getKind() == ClassKind.TRAIT;
|
||||||
boolean isDefinitelyAbstract = isTrait && !isBodyPresent;
|
boolean isDefinitelyAbstract = isTrait && !isBodyPresent;
|
||||||
Modality basicModality = isTrait ? Modality.OPEN : Modality.FINAL;
|
Modality basicModality = isTrait && !Visibilities.isPrivate(visibility) ? Modality.OPEN : Modality.FINAL;
|
||||||
defaultModality = isDefinitelyAbstract ? Modality.ABSTRACT : basicModality;
|
defaultModality = isDefinitelyAbstract ? Modality.ABSTRACT : basicModality;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -710,10 +710,10 @@ public class DescriptorResolver {
|
|||||||
boolean isVar = property.isVar();
|
boolean isVar = property.isVar();
|
||||||
|
|
||||||
boolean hasBody = hasBody(property);
|
boolean hasBody = hasBody(property);
|
||||||
Modality modality = containingDeclaration instanceof ClassDescriptor
|
|
||||||
? resolveModalityFromModifiers(property, getDefaultModality(containingDeclaration, hasBody))
|
|
||||||
: Modality.FINAL;
|
|
||||||
Visibility visibility = resolveVisibilityFromModifiers(property, getDefaultVisibility(property, containingDeclaration));
|
Visibility visibility = resolveVisibilityFromModifiers(property, getDefaultVisibility(property, containingDeclaration));
|
||||||
|
Modality modality = containingDeclaration instanceof ClassDescriptor
|
||||||
|
? resolveModalityFromModifiers(property, getDefaultModality(containingDeclaration, visibility, hasBody))
|
||||||
|
: Modality.FINAL;
|
||||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||||
containingDeclaration,
|
containingDeclaration,
|
||||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, modifierList, trace),
|
annotationResolver.resolveAnnotationsWithoutArguments(scope, modifierList, trace),
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ class FunctionDescriptorResolver(
|
|||||||
|
|
||||||
val returnType = function.getTypeReference()?.let { typeResolver.resolveType(innerScope, it, trace, true) }
|
val returnType = function.getTypeReference()?.let { typeResolver.resolveType(innerScope, it, trace, true) }
|
||||||
|
|
||||||
val modality = resolveModalityFromModifiers(function, getDefaultModality(containingDescriptor, function.hasBody()))
|
|
||||||
val visibility = resolveVisibilityFromModifiers(function, getDefaultVisibility(function, containingDescriptor))
|
val visibility = resolveVisibilityFromModifiers(function, getDefaultVisibility(function, containingDescriptor))
|
||||||
|
val modality = resolveModalityFromModifiers(function, getDefaultModality(containingDescriptor, visibility, function.hasBody()))
|
||||||
functionDescriptor.initialize(
|
functionDescriptor.initialize(
|
||||||
receiverType,
|
receiverType,
|
||||||
getDispatchReceiverParameterIfNeeded(containingDescriptor),
|
getDispatchReceiverParameterIfNeeded(containingDescriptor),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
internal trait One {
|
internal trait One {
|
||||||
private open fun boo(): kotlin.Int
|
private final fun boo(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public abstract fun foo(): kotlin.Int
|
public abstract fun foo(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
@@ -9,7 +9,7 @@ internal trait One {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal trait OneImpl : One {
|
internal trait OneImpl : One {
|
||||||
invisible_fake open override /*1*/ /*fake_override*/ fun boo(): kotlin.Int
|
invisible_fake final override /*1*/ /*fake_override*/ fun boo(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ fun foo(): kotlin.Int
|
public open override /*1*/ fun foo(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
@@ -18,7 +18,7 @@ internal trait OneImpl : One {
|
|||||||
|
|
||||||
internal final class Test1 : TwoImpl, OneImpl {
|
internal final class Test1 : TwoImpl, OneImpl {
|
||||||
public constructor Test1()
|
public constructor Test1()
|
||||||
invisible_fake open override /*1*/ /*fake_override*/ fun boo(): kotlin.Int
|
invisible_fake final override /*1*/ /*fake_override*/ fun boo(): kotlin.Int
|
||||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*2*/ /*fake_override*/ fun foo(): kotlin.Int
|
public open override /*2*/ /*fake_override*/ fun foo(): kotlin.Int
|
||||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
@@ -27,7 +27,7 @@ internal final class Test1 : TwoImpl, OneImpl {
|
|||||||
|
|
||||||
internal final class Test2 : One, Two {
|
internal final class Test2 : One, Two {
|
||||||
public constructor Test2(/*0*/ a: One)
|
public constructor Test2(/*0*/ a: One)
|
||||||
internal open /*delegation*/ fun boo(): kotlin.Int
|
invisible_fake final override /*1*/ /*fake_override*/ fun boo(): kotlin.Int
|
||||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*2*/ /*delegation*/ fun foo(): kotlin.Int
|
public open override /*2*/ /*delegation*/ fun foo(): kotlin.Int
|
||||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
@@ -36,7 +36,7 @@ internal final class Test2 : One, Two {
|
|||||||
|
|
||||||
internal final class Test3 : Two, One {
|
internal final class Test3 : Two, One {
|
||||||
public constructor Test3(/*0*/ a: One, /*1*/ b: Two)
|
public constructor Test3(/*0*/ a: One, /*1*/ b: Two)
|
||||||
internal open /*delegation*/ fun boo(): kotlin.Int
|
invisible_fake final override /*1*/ /*fake_override*/ fun boo(): kotlin.Int
|
||||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*2*/ /*delegation*/ fun foo(): kotlin.Int
|
public open override /*2*/ /*delegation*/ fun foo(): kotlin.Int
|
||||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ internal abstract class A {
|
|||||||
|
|
||||||
internal trait B {
|
internal trait B {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
kotlin.inline() private open fun good1(): kotlin.Unit
|
kotlin.inline() private final fun good1(): kotlin.Unit
|
||||||
kotlin.inline() public final fun good2(): kotlin.Unit
|
kotlin.inline() public final fun good2(): kotlin.Unit
|
||||||
kotlin.inline() protected final fun good3(): kotlin.Unit
|
kotlin.inline() protected final fun good3(): kotlin.Unit
|
||||||
kotlin.inline() internal final fun good4(): kotlin.Unit
|
kotlin.inline() internal final fun good4(): kotlin.Unit
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package
|
|||||||
package test {
|
package test {
|
||||||
|
|
||||||
internal trait A {
|
internal trait A {
|
||||||
private open val a: kotlin.String
|
private final val a: kotlin.String
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|||||||
Reference in New Issue
Block a user