Fixed error type case
This commit is contained in:
@@ -58,7 +58,7 @@ public object SuperClassNotInitialized : JetIntentionActionsFactory() {
|
||||
val constructorToUse = constructors.singleOrNull()
|
||||
?: constructors.singleOrNull { it.isPrimary() } //TODO: should we select it automatically in this case?
|
||||
//TODO: multiple
|
||||
if (constructorToUse != null && constructorToUse.getValueParameters().isNotEmpty()) {
|
||||
if (constructorToUse != null && constructorToUse.getValueParameters().isNotEmpty() && constructorToUse.getValueParameters().none { it.getType().isError() }) {
|
||||
val superType = classDescriptor.getTypeConstructor().getSupertypes().first { it.getConstructor().getDeclarationDescriptor() == superClass }
|
||||
val typeArgsMap = superClass.getTypeConstructor().getParameters().zip(superType.getArguments()).toMap()
|
||||
val substitutor = TypeUtils.makeSubstitutorForTypeParametersMap(typeArgsMap)
|
||||
@@ -108,7 +108,6 @@ public object SuperClassNotInitialized : JetIntentionActionsFactory() {
|
||||
if (!superParameters.isEmpty()) {
|
||||
val parameterList = classDeclaration.getOrCreatePrimaryConstructorParameterList()
|
||||
for (parameter in superParameters) {
|
||||
//TODO: what if type is error?
|
||||
val name = renderer.renderName(parameter.getName())
|
||||
val parameterText = name + ":" + renderer.renderType(parameter.getType())
|
||||
val newParameter = parameterList.addParameter(factory.createParameter(parameterText))
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// "class org.jetbrains.kotlin.idea.quickfix.SuperClassNotInitialized$AddParametersFix" "false"
|
||||
// ACTION: Change to constructor invocation
|
||||
// ERROR: Unresolved reference: XXX
|
||||
// ERROR: This type has a constructor, and thus must be initialized here
|
||||
open class Base(p1: XXX)
|
||||
|
||||
class C : Base<caret>
|
||||
@@ -3993,6 +3993,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/supertypeInitialization"), Pattern.compile("^(\\w+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("baseConstructorError.kt")
|
||||
public void testBaseConstructorError() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/supertypeInitialization/baseConstructorError.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("createConstructor.kt")
|
||||
public void testCreateConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/supertypeInitialization/createConstructor.kt");
|
||||
|
||||
Reference in New Issue
Block a user