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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// IS_APPLICABLE: false
|
||||
annotation class AClass <caret>public constructor()
|
||||
@@ -0,0 +1 @@
|
||||
class RegularClass <caret>private constructor()
|
||||
+1
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user