Change Signature: Add tests for secondary constructors and delegation calls
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
class K: J {
|
||||||
|
constructor(a: Int): super(a, "foo") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
J(1, "foo")
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class J {
|
||||||
|
public J(int n, String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class K: J {
|
||||||
|
constructor(a: Int): super(a) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
J(1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class J {
|
||||||
|
public <caret>J(int n) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class J extends A {
|
||||||
|
public J() {
|
||||||
|
super("foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
public J(int a) {
|
||||||
|
|
||||||
|
super("foo");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
open class A {
|
||||||
|
<caret>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,9 @@
|
|||||||
|
class J extends A {
|
||||||
|
public J() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public J(int a) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
open class A {
|
||||||
|
<caret>constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(a: Int) : this() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B: A {
|
||||||
|
constructor() : super() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class C: A {
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D: A() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A()
|
||||||
|
}
|
||||||
+24
@@ -728,6 +728,30 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
|||||||
doTest(changeInfo);
|
doTest(changeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSecondaryConstructor() throws Exception {
|
||||||
|
JetChangeInfo changeInfo = getChangeInfo();
|
||||||
|
changeInfo.addParameter(new JetParameterInfo(-1, "s", KotlinBuiltIns.getInstance().getStringType(), null, "\"foo\"", null, null));
|
||||||
|
doTest(changeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testJavaConstructorInDelegationCall() throws Exception {
|
||||||
|
doJavaTest(
|
||||||
|
new JavaRefactoringProvider() {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
ParameterInfoImpl[] getNewParameters(@NotNull PsiMethod method) {
|
||||||
|
ParameterInfoImpl[] newParameters = super.getNewParameters(method);
|
||||||
|
newParameters = Arrays.copyOf(newParameters, newParameters.length + 1);
|
||||||
|
|
||||||
|
PsiType paramType = PsiType.getJavaLangString(getPsiManager(), GlobalSearchScope.allScope(getProject()));
|
||||||
|
newParameters[newParameters.length - 1] = new ParameterInfoImpl(-1, "s", paramType, "\"foo\"");
|
||||||
|
|
||||||
|
return newParameters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected String getTestDataPath() {
|
protected String getTestDataPath() {
|
||||||
|
|||||||
Reference in New Issue
Block a user