K1: add deprecation warning for property/field pair with different types

#KT-57905 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-04-18 18:45:24 +02:00
committed by Space Team
parent 2100f08655
commit 41e551e321
13 changed files with 163 additions and 2 deletions
@@ -0,0 +1,19 @@
// ISSUE: KT-57905
// FILE: Base.java
public class Base {
String value = null;
String extension = null;
}
// FILE: Main.kt
class Derived: Base() {
val value: Int = 42
val something: String = <!INITIALIZER_TYPE_MISMATCH!>value<!>
val String.extension: Int get() = 42
fun String.foo() {
// K1 & K2 work in the same way here (resolve to an extension property)
val something: String = <!INITIALIZER_TYPE_MISMATCH!>extension<!>
}
}
@@ -0,0 +1,19 @@
// ISSUE: KT-57905
// FILE: Base.java
public class Base {
String value = null;
String extension = null;
}
// FILE: Main.kt
class Derived: Base() {
val value: Int = 42
val something: String = <!BASE_CLASS_FIELD_WITH_DIFFERENT_SIGNATURE_THAN_DERIVED_CLASS_PROPERTY!>value<!>
val String.extension: Int get() = 42
fun String.foo() {
// K1 & K2 work in the same way here (resolve to an extension property)
val something: String = <!TYPE_MISMATCH!>extension<!>
}
}
@@ -0,0 +1,16 @@
// ISSUE: KT-57905
// FILE: BasicSliderUI.java
public class BasicSliderUI {
Rectangle thumbRect = null;
}
// FILE: Main.kt
class Rectangle
class TimelineSliderUI: BasicSliderUI() {
// K1: ok
// K2: INITIALIZER_TYPE_MISMATCH (actual kotlin/Function0<kotlin/Function0<Rectangle>>, expected kotlin/Function0<Rectangle>)
val thumbRect: () -> Rectangle = <!INITIALIZER_TYPE_MISMATCH!>{ thumbRect }<!>
}
@@ -0,0 +1,16 @@
// ISSUE: KT-57905
// FILE: BasicSliderUI.java
public class BasicSliderUI {
Rectangle thumbRect = null;
}
// FILE: Main.kt
class Rectangle
class TimelineSliderUI: BasicSliderUI() {
// K1: ok
// K2: INITIALIZER_TYPE_MISMATCH (actual kotlin/Function0<kotlin/Function0<Rectangle>>, expected kotlin/Function0<Rectangle>)
val thumbRect: () -> Rectangle = { <!BASE_CLASS_FIELD_WITH_DIFFERENT_SIGNATURE_THAN_DERIVED_CLASS_PROPERTY!>thumbRect<!> }
}