KT-4295 Wrong diagnostic about "weaken access privilege" when override properties in constructor
#KT-4295 Fixed
This commit is contained in:
@@ -1314,7 +1314,7 @@ public class DescriptorResolver {
|
|||||||
classDescriptor,
|
classDescriptor,
|
||||||
valueParameter.getAnnotations(),
|
valueParameter.getAnnotations(),
|
||||||
resolveModalityFromModifiers(parameter, Modality.FINAL),
|
resolveModalityFromModifiers(parameter, Modality.FINAL),
|
||||||
resolveVisibilityFromModifiers(parameter, Visibilities.INTERNAL),
|
resolveVisibilityFromModifiers(parameter, getDefaultVisibility(parameter, classDescriptor)),
|
||||||
isMutable,
|
isMutable,
|
||||||
name,
|
name,
|
||||||
CallableMemberDescriptor.Kind.DECLARATION
|
CallableMemberDescriptor.Kind.DECLARATION
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
open class Base {
|
||||||
|
protected open val prot: Int = 1
|
||||||
|
internal open val int: Int = 1
|
||||||
|
public open val pub: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
class Child(
|
||||||
|
override val prot: Int,
|
||||||
|
override val int: Int,
|
||||||
|
override val pub: Int
|
||||||
|
) : Base()
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//ALLOW_AST_ACCESS
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
open class Base {
|
||||||
|
protected open val prot = 1
|
||||||
|
internal open val int = 1
|
||||||
|
public open val pub: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
class Child(
|
||||||
|
override val prot: Int,
|
||||||
|
override val int: Int,
|
||||||
|
override val pub: Int
|
||||||
|
) : Base()
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
internal open class Base {
|
||||||
|
/*primary*/ public constructor Base()
|
||||||
|
internal open val int: kotlin.Int = 1
|
||||||
|
internal open fun <get-int>(): kotlin.Int
|
||||||
|
protected open val prot: kotlin.Int = 1
|
||||||
|
protected open fun <get-prot>(): kotlin.Int
|
||||||
|
public open val pub: kotlin.Int = 1
|
||||||
|
public open fun <get-pub>(): kotlin.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final class Child : test.Base {
|
||||||
|
/*primary*/ public constructor Child(/*0*/ prot: kotlin.Int, /*1*/ int: kotlin.Int, /*2*/ pub: kotlin.Int)
|
||||||
|
internal open override /*1*/ val int: kotlin.Int
|
||||||
|
internal open override /*1*/ fun <get-int>(): kotlin.Int
|
||||||
|
protected open override /*1*/ val prot: kotlin.Int
|
||||||
|
protected open override /*1*/ fun <get-prot>(): kotlin.Int
|
||||||
|
public open override /*1*/ val pub: kotlin.Int
|
||||||
|
public open override /*1*/ fun <get-pub>(): kotlin.Int
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
//ALLOW_AST_ACCESS
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
open class Base {
|
||||||
|
protected open val prot: Int = 1
|
||||||
|
internal open val int: Int = 1
|
||||||
|
public open val pub: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
class Child(
|
||||||
|
public override val prot: Int,
|
||||||
|
public override val int: Int,
|
||||||
|
public override val pub: Int
|
||||||
|
) : Base()
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
internal open class Base {
|
||||||
|
/*primary*/ public constructor Base()
|
||||||
|
internal open val int: kotlin.Int = 1
|
||||||
|
internal open fun <get-int>(): kotlin.Int
|
||||||
|
protected open val prot: kotlin.Int = 1
|
||||||
|
protected open fun <get-prot>(): kotlin.Int
|
||||||
|
public open val pub: kotlin.Int = 1
|
||||||
|
public open fun <get-pub>(): kotlin.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final class Child : test.Base {
|
||||||
|
/*primary*/ public constructor Child(/*0*/ prot: kotlin.Int, /*1*/ int: kotlin.Int, /*2*/ pub: kotlin.Int)
|
||||||
|
public open override /*1*/ val int: kotlin.Int
|
||||||
|
public open override /*1*/ fun <get-int>(): kotlin.Int
|
||||||
|
public open override /*1*/ val prot: kotlin.Int
|
||||||
|
public open override /*1*/ fun <get-prot>(): kotlin.Int
|
||||||
|
public open override /*1*/ val pub: kotlin.Int
|
||||||
|
public open override /*1*/ fun <get-pub>(): kotlin.Int
|
||||||
|
}
|
||||||
@@ -6117,6 +6117,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest("compiler/testData/diagnostics/tests/override/ParentInheritsManyImplementations.kt");
|
doTest("compiler/testData/diagnostics/tests/override/ParentInheritsManyImplementations.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PropertyInConstructor.kt")
|
||||||
|
public void testPropertyInConstructor() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/override/PropertyInConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ProtectedAndPrivateFromSupertypes.kt")
|
@TestMetadata("ProtectedAndPrivateFromSupertypes.kt")
|
||||||
public void testProtectedAndPrivateFromSupertypes() throws Exception {
|
public void testProtectedAndPrivateFromSupertypes() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.kt");
|
doTest("compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.kt");
|
||||||
|
|||||||
@@ -3023,6 +3023,16 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
|||||||
doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/visibility/PrivateTopLevelVal.kt");
|
doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/visibility/PrivateTopLevelVal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PropertyInConstructor.kt")
|
||||||
|
public void testPropertyInConstructor() throws Exception {
|
||||||
|
doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PropertyInConstructorExplicitVisibility.kt")
|
||||||
|
public void testPropertyInConstructorExplicitVisibility() throws Exception {
|
||||||
|
doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TopLevelVarWithPrivateSetter.kt")
|
@TestMetadata("TopLevelVarWithPrivateSetter.kt")
|
||||||
public void testTopLevelVarWithPrivateSetter() throws Exception {
|
public void testTopLevelVarWithPrivateSetter() throws Exception {
|
||||||
doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt");
|
doTestCompiledKotlin("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt");
|
||||||
|
|||||||
+10
@@ -1491,6 +1491,16 @@ public class LazyResolveRecursiveComparingTestGenerated extends AbstractLazyReso
|
|||||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PrivateTopLevelVal.kt");
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PrivateTopLevelVal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PropertyInConstructor.kt")
|
||||||
|
public void testPropertyInConstructor() throws Exception {
|
||||||
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PropertyInConstructorExplicitVisibility.kt")
|
||||||
|
public void testPropertyInConstructorExplicitVisibility() throws Exception {
|
||||||
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TopLevelVarWithPrivateSetter.kt")
|
@TestMetadata("TopLevelVarWithPrivateSetter.kt")
|
||||||
public void testTopLevelVarWithPrivateSetter() throws Exception {
|
public void testTopLevelVarWithPrivateSetter() throws Exception {
|
||||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt");
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt");
|
||||||
|
|||||||
@@ -1491,6 +1491,16 @@ public class LazyResolveByStubTestGenerated extends AbstractLazyResolveByStubTes
|
|||||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PrivateTopLevelVal.kt");
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PrivateTopLevelVal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PropertyInConstructor.kt")
|
||||||
|
public void testPropertyInConstructor() throws Exception {
|
||||||
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PropertyInConstructorExplicitVisibility.kt")
|
||||||
|
public void testPropertyInConstructorExplicitVisibility() throws Exception {
|
||||||
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/PropertyInConstructorExplicitVisibility.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TopLevelVarWithPrivateSetter.kt")
|
@TestMetadata("TopLevelVarWithPrivateSetter.kt")
|
||||||
public void testTopLevelVarWithPrivateSetter() throws Exception {
|
public void testTopLevelVarWithPrivateSetter() throws Exception {
|
||||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt");
|
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadJava/compiledKotlin/visibility/TopLevelVarWithPrivateSetter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user