Create from Usage: Always insert parentheses around secondary constructor parameter list
#KT-10912 Fixed
This commit is contained in:
+3
-1
@@ -436,7 +436,9 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
fun renderParamList(): String {
|
||||
val prefix = if (classKind == ClassKind.ANNOTATION_CLASS) "val " else ""
|
||||
val list = callableInfo.parameterInfos.indices.map { i -> "${prefix}p$i: Any" }.joinToString(", ")
|
||||
return if (callableInfo.parameterInfos.isNotEmpty() || callableInfo.kind == CallableKind.FUNCTION) "($list)" else list
|
||||
return if (callableInfo.parameterInfos.isNotEmpty()
|
||||
|| callableInfo.kind == CallableKind.FUNCTION
|
||||
|| callableInfo.kind == CallableKind.SECONDARY_CONSTRUCTOR) "($list)" else list
|
||||
}
|
||||
|
||||
val paramList = when (callableInfo.kind) {
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create secondary constructor" "true"
|
||||
// ERROR: Primary constructor call expected
|
||||
class Creation(val f: Int)
|
||||
val v = Creation(<caret>)
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create secondary constructor" "true"
|
||||
// ERROR: Primary constructor call expected
|
||||
class Creation(val f: Int) {
|
||||
constructor() {
|
||||
//To change body of created constructors use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
val v = Creation()
|
||||
@@ -2601,6 +2601,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noParameters.kt")
|
||||
public void testNoParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/noParameters.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("superCall.kt")
|
||||
public void testSuperCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCall.kt");
|
||||
|
||||
Reference in New Issue
Block a user