Fix for non-accessible constructor case
This commit is contained in:
@@ -48,6 +48,7 @@ public object SuperClassNotInitialized : JetIntentionActionsFactory() {
|
|||||||
val superClass = (type.getConstructor().getDeclarationDescriptor() as? ClassDescriptor) ?: return null
|
val superClass = (type.getConstructor().getDeclarationDescriptor() as? ClassDescriptor) ?: return null
|
||||||
val classDescriptor = delegator.getResolutionFacade().resolveToDescriptor(classOrObjectDeclaration) as ClassDescriptor
|
val classDescriptor = delegator.getResolutionFacade().resolveToDescriptor(classOrObjectDeclaration) as ClassDescriptor
|
||||||
val constructors = superClass.getConstructors().filter { it.isVisible(classDescriptor) }
|
val constructors = superClass.getConstructors().filter { it.isVisible(classDescriptor) }
|
||||||
|
if (constructors.isEmpty()) return null // no accessible constructor
|
||||||
|
|
||||||
val fixes = ArrayList<IntentionAction>()
|
val fixes = ArrayList<IntentionAction>()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// "class org.jetbrains.kotlin.idea.quickfix.SuperClassNotInitialized$AddParenthesisFix" "false"
|
||||||
|
// ERROR: This type has a constructor, and thus must be initialized here
|
||||||
|
open class Base private(p: Int)
|
||||||
|
|
||||||
|
class C : Base<caret>
|
||||||
@@ -3987,6 +3987,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noAccessibleConstructors.kt")
|
||||||
|
public void testNoAccessibleConstructors() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/supertypeInitialization/noAccessibleConstructors.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noParameters.kt")
|
@TestMetadata("noParameters.kt")
|
||||||
public void testNoParameters() throws Exception {
|
public void testNoParameters() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/supertypeInitialization/noParameters.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/supertypeInitialization/noParameters.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user