Codegen: Fix origin of overloaded methods generated for constructors with @JvmOverloads

Find Usages: Add tests for declarations annotated with @JvmOverloads
 #KT-8534 Fixed
This commit is contained in:
Alexey Sedunov
2015-10-28 12:28:44 +03:00
parent b9ed3b91be
commit 1de3faf3f5
12 changed files with 115 additions and 6 deletions
@@ -0,0 +1,12 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
// OPTIONS: usages
@file:JvmName("Foo")
@JvmOverloads
fun <caret>foo(
x: Int = 0,
y: Double = 0.0,
z: String = "0"
) {
}
@@ -0,0 +1,17 @@
class Usages {
void foo() {
Foo.foo();
}
void fooX() {
Foo.foo(1);
}
void fooXY() {
Foo.foo(1, 1.0);
}
void fooXYZ() {
Foo.foo(1, 1.0, "1");
}
}
@@ -0,0 +1,4 @@
Unclassified usage (11: 13) Foo.foo(1, 1.0);
Unclassified usage (15: 13) Foo.foo(1, 1.0, "1");
Unclassified usage (3: 13) Foo.foo();
Unclassified usage (7: 13) Foo.foo(1);
@@ -0,0 +1,7 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtPrimaryConstructor
// OPTIONS: usages
public class A @JvmOverloads <caret>constructor (
public val x: Int = 0,
public val y: Double = 0.0,
public val z: String = "0"
)
@@ -0,0 +1,17 @@
public class Usages {
void createA() {
new A();
}
void createAx() {
new A(1);
}
void createAxy() {
new A(1, 1.0);
}
void createAxyz() {
new A(1, 1.0, "1");
}
}
@@ -0,0 +1,4 @@
New instance creation (11: 13) new A(1, 1.0);
New instance creation (15: 13) new A(1, 1.0, "1");
New instance creation (3: 13) new A();
New instance creation (7: 13) new A(1);
@@ -0,0 +1,5 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtSecondaryConstructor
// OPTIONS: usages
public class A {
@JvmOverloads <caret>constructor(x: Int = 0, y: Double = 0.0, z: String = "0")
}
@@ -0,0 +1,17 @@
public class Usages {
void createA() {
new A();
}
void createAx() {
new A(1);
}
void createAxy() {
new A(1, 1.0);
}
void createAxyz() {
new A(1, 1.0, "1");
}
}
@@ -0,0 +1,4 @@
New instance creation (11: 13) new A(1, 1.0);
New instance creation (15: 13) new A(1, 1.0, "1");
New instance creation (3: 13) new A();
New instance creation (7: 13) new A(1);