KT-46146 'protected' is unavailable for primary constructors

Prior to this commit intention to change primary constructor visibility
to 'protected' was filtered out.
This commit is contained in:
Andrei Klunnyi
2021-05-05 12:28:50 +03:00
committed by Space
parent 7388e60869
commit 686368749a
6 changed files with 16 additions and 0 deletions
@@ -366,6 +366,7 @@ fun KtModifierListOwner.canBeProtected(): Boolean {
return when (parent) {
is KtClassBody -> parent.parent is KtClass
is KtParameterList -> parent.parent is KtPrimaryConstructor
is KtClass -> !this.isAnnotationClassPrimaryConstructor()
else -> false
}
}
@@ -0,0 +1,2 @@
// IS_APPLICABLE: false
annotation class AClass <caret>public constructor()
@@ -0,0 +1 @@
class RegularClass <caret>private constructor()
@@ -0,0 +1 @@
class RegularClass <caret>protected constructor()
@@ -2,6 +2,7 @@
// ACTION: Create test
// ACTION: Make primary constructor internal
// ACTION: Make primary constructor private
// ACTION: Make primary constructor protected
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Extract 'C' from current file
// ACTION: Rename file to C.kt
@@ -3658,6 +3658,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
runTest("idea/testData/intentions/changeVisibility/protected/noModifier.kt");
}
@TestMetadata("notForAnnotationPrimaryConstructor.kt")
public void testNotForAnnotationPrimaryConstructor() throws Exception {
runTest("idea/testData/intentions/changeVisibility/protected/notForAnnotationPrimaryConstructor.kt");
}
@TestMetadata("notForNonValParameter.kt")
public void testNotForNonValParameter() throws Exception {
runTest("idea/testData/intentions/changeVisibility/protected/notForNonValParameter.kt");
@@ -3678,6 +3683,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
runTest("idea/testData/intentions/changeVisibility/protected/notForTopLevel.kt");
}
@TestMetadata("primaryConstructor.kt")
public void testPrimaryConstructor() throws Exception {
runTest("idea/testData/intentions/changeVisibility/protected/primaryConstructor.kt");
}
@TestMetadata("propertySetter.kt")
public void testPropertySetter() throws Exception {
runTest("idea/testData/intentions/changeVisibility/protected/propertySetter.kt");