Change Signature: enable on primary constructor keyword (#2482)

#KT-19744 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-06-11 18:10:12 +09:00
committed by GitHub
parent 957a927790
commit cbbdec5898
4 changed files with 65 additions and 0 deletions
@@ -79,6 +79,7 @@ class KotlinChangeSignatureHandler : ChangeSignatureHandler {
) return elementParent
}
if (elementParent is KtPrimaryConstructor && elementParent.getConstructorKeyword() === element) return elementParent
if (elementParent is KtSecondaryConstructor && elementParent.getConstructorKeyword() === element) return elementParent
element.getStrictParentOfType<KtParameterList>()?.let { parameterList ->
@@ -0,0 +1,25 @@
open class A internal constructor(s: String) {
constructor(a: Int) : this("foo") {
}
}
open class B : A {
constructor() : super("foo") {
}
}
open class C : A {
constructor() : super("foo") {
}
}
class D : A("foo") {
}
fun test() {
A("foo")
}
@@ -0,0 +1,25 @@
open class A internal <caret>constructor() {
constructor(a: Int) : this() {
}
}
open class B : A {
constructor() : super() {
}
}
open class C : A {
constructor() {
}
}
class D : A() {
}
fun test() {
A()
}
@@ -808,6 +808,20 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() {
}
}
fun testPrimaryConstructorOnConstructorKeyword() = doTest {
val defaultValueForCall = KtPsiFactory(project).createExpression("\"foo\"")
addParameter(
KotlinParameterInfo(
originalBaseFunctionDescriptor,
-1,
"s",
KotlinTypeInfo(false, BUILT_INS.stringType),
null,
defaultValueForCall
)
)
}
fun testJavaConstructorInDelegationCall() {
doJavaTest { newParameters.add(ParameterInfoImpl(-1, "s", stringPsiType, "\"foo\"")) }
}