Fixed KNPE in convert primary constructor to secondary #KT-14745 Fixed

This commit is contained in:
mglukhikh
2017-01-16 13:30:41 +03:00
parent cd33a40612
commit 93b2c56bb4
4 changed files with 21 additions and 1 deletions
@@ -80,7 +80,7 @@ class ConvertPrimaryConstructorToSecondaryIntention : SelfTargetingIntention<KtP
val annotations = valueParameter.annotationEntries.joinToString(separator = " ") { it.text }
val vararg = if (valueParameter.isVarArg) VARARG_KEYWORD.value else ""
param("$annotations $vararg ${valueParameter.name ?: ""}",
valueParameter.typeReference!!.text, valueParameter.defaultValue?.text)
valueParameter.typeReference?.text ?: "", valueParameter.defaultValue?.text)
}
noReturnType()
for (superTypeEntry in klass.getSuperTypeListEntries()) {
@@ -0,0 +1,4 @@
// SKIP_ERRORS_BEFORE
// SKIP_ERRORS_AFTER
class My<caret>(val x)
@@ -0,0 +1,10 @@
// SKIP_ERRORS_BEFORE
// SKIP_ERRORS_AFTER
class My {
val x
constructor(x:) {
this.x = x
}
}
@@ -4862,6 +4862,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("noArgType.kt")
public void testNoArgType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/noArgType.kt");
doTest(fileName);
}
@TestMetadata("paramsAndProperties.kt")
public void testParamsAndProperties() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/paramsAndProperties.kt");