"Convert to secondary constructor": Fix false positive with delegation #KT-27061 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
af1fc5b668
commit
c1013cc198
+2
-1
@@ -42,7 +42,8 @@ class ConvertPrimaryConstructorToSecondaryIntention : SelfTargetingIntention<KtP
|
||||
) {
|
||||
override fun isApplicableTo(element: KtPrimaryConstructor, caretOffset: Int): Boolean {
|
||||
val containingClass = element.containingClassOrObject as? KtClass ?: return false
|
||||
if (containingClass.isAnnotation() || containingClass.isData()) return false;
|
||||
if (containingClass.isAnnotation() || containingClass.isData()
|
||||
|| containingClass.superTypeListEntries.any { it is KtDelegatedSuperTypeEntry }) return false
|
||||
return element.valueParameters.all { !it.hasValOrVar() || it.annotationEntries.isEmpty() }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
interface Base
|
||||
|
||||
class Foo(<caret>s: String, b: Base): Base by b
|
||||
@@ -5755,6 +5755,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
runTest("idea/testData/intentions/convertPrimaryConstructorToSecondary/defaultValueChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
runTest("idea/testData/intentions/convertPrimaryConstructorToSecondary/delegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
runTest("idea/testData/intentions/convertPrimaryConstructorToSecondary/enum.kt");
|
||||
|
||||
Reference in New Issue
Block a user