Convert primary constructor to secondary: KNPE fixed #KT-14745 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-11-14 18:56:37 +03:00
parent 13b2c2cd24
commit d4995c07f7
4 changed files with 13 additions and 1 deletions
@@ -79,7 +79,7 @@ class ConvertPrimaryConstructorToSecondaryIntention : SelfTargetingIntention<KtP
for (valueParameter in element.valueParameters) {
val annotations = valueParameter.annotationEntries.joinToString(separator = " ") { it.text }
val vararg = if (valueParameter.isVarArg) VARARG_KEYWORD.value else ""
param("$annotations $vararg ${valueParameter.name!!}",
param("$annotations $vararg ${valueParameter.name ?: ""}",
valueParameter.typeReference!!.text, valueParameter.defaultValue?.text)
}
noReturnType()
@@ -0,0 +1,2 @@
class My<caret>(: Int)
@@ -0,0 +1,4 @@
class My {
constructor(: Int)
}
@@ -4580,6 +4580,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("noArgName.kt")
public void testNoArgName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/noArgName.kt");
doTest(fileName);
}
@TestMetadata("paramsAndProperties.kt")
public void testParamsAndProperties() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/paramsAndProperties.kt");