7c90fbe4de
Do not call `isError()` on property's type right after creation of
PropertyGetterDescriptor because the property has no getter yet (it's created
but not yet stored to the property, that happens a bit later), and `isError()`
leads to computation of the delegate type, which for delegated properties
performs some complex resolution (see `VariableTypeResolver#process`) which
relies on the fact that the property already has a getter.
Since the purpose of the original change (883e2e4d) was to support a quick fix
which would add the type to a property in an expression like "val x get() =
...", check the type (or initializer) presence in the PSI instead, this is
safer and is still suitable for the quick fix.
Also fix arguments to "wrong getter type" diagnostic: previously something
useless like "expected Int, actual Int" was reported
#KT-11809 Fixed
34 lines
797 B
Kotlin
Vendored
34 lines
797 B
Kotlin
Vendored
class A() {
|
|
var x: Int = 0
|
|
get() = <!TYPE_MISMATCH!>"s"<!>
|
|
set(value: <!WRONG_SETTER_PARAMETER_TYPE!>String<!>) {
|
|
field = <!TYPE_MISMATCH!>value<!>
|
|
}
|
|
val y: Int
|
|
get(): <!WRONG_GETTER_RETURN_TYPE(Int; String)!>String<!> = "s"
|
|
val z: Int
|
|
get() {
|
|
return <!TYPE_MISMATCH!>"s"<!>
|
|
}
|
|
|
|
var a: Any = 1
|
|
set(v: <!WRONG_SETTER_PARAMETER_TYPE!>String<!>) {
|
|
field = v
|
|
}
|
|
val b: Int
|
|
get(): <!WRONG_GETTER_RETURN_TYPE!>Any<!> = "s"
|
|
val c: Int
|
|
get() {
|
|
return 1
|
|
}
|
|
val d = 1
|
|
get() {
|
|
return field
|
|
}
|
|
val e = 1
|
|
get(): <!WRONG_GETTER_RETURN_TYPE!>String<!> {
|
|
return <!TYPE_MISMATCH!>field<!>
|
|
}
|
|
|
|
}
|