Resolve "componentN" functions for data classes
Reuse existing (but not used) VALUE_PARAMETER_AS_PROPERTY in BindingContext to store mapping from constructor's value parameters to property descriptors. Create a new slice DATA_CLASS_COMPONENT_FUNCTION to store mapping from constructor's value parameters to generated componentN functions.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
data class A(x: Int, y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.<!UNRESOLVED_REFERENCE!>component1<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
open data class A(private val x: Int)
|
||||
|
||||
class B : A(1) {
|
||||
fun component1(): String = ""
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val b = B()
|
||||
b.component1() : String
|
||||
(b : A).<!INVISIBLE_MEMBER!>component1<!>() : Int
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
open data class A(private val x: Int, protected val y: String, public val z: Any)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.<!INVISIBLE_MEMBER!>component1<!>()
|
||||
a.<!INVISIBLE_MEMBER!>component2<!>()
|
||||
a.component3()
|
||||
}
|
||||
|
||||
class B : A(42, "", "") {
|
||||
fun foo() {
|
||||
this.<!INVISIBLE_MEMBER!>component1<!>()
|
||||
this.component2()
|
||||
this.component3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
open data class A(val x: Int, val y: String)
|
||||
|
||||
class B : A(42, "OK") {
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun component1(): Int = 21
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun component2(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Int<!> = 21
|
||||
}
|
||||
|
||||
fun foo(b: B) {
|
||||
b.component1()
|
||||
b.component2()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(val component1: Int)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1()
|
||||
a.component1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A()
|
||||
|
||||
fun foo(a: A) {
|
||||
a.<!UNRESOLVED_REFERENCE!>component1<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(val x: Int, y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1() : Int
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(var x: Int, y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1() : Int
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
val (b, c) = a
|
||||
b : Int
|
||||
c : String
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(arr: Array<A>) {
|
||||
for ((b, c) in arr) {
|
||||
b : Int
|
||||
c : String
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.<!UNRESOLVED_REFERENCE!>component1<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(val x: Int)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1() : Int
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(x: Int, val y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1() : String
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(x: Int, var y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1() : String
|
||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1() : Int
|
||||
a.component2() : String
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data class A(var x: Int, var y: String)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.component1() : Int
|
||||
a.component2() : String
|
||||
}
|
||||
Reference in New Issue
Block a user