[FIR] Add 3 type mismatch diagnostics
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
open class A {
|
||||
open var test: Number = 10
|
||||
}
|
||||
|
||||
open class B : A {
|
||||
override var test: Double = 20.0
|
||||
}
|
||||
|
||||
class C() : A() {
|
||||
override var test: <!VAR_TYPE_MISMATCH_ON_OVERRIDE!>String<!> = "Test"
|
||||
}
|
||||
|
||||
open class D() : B() {
|
||||
override var test: <!VAR_TYPE_MISMATCH_ON_OVERRIDE!>Char<!> = '\n'
|
||||
}
|
||||
|
||||
class E<T : Double>(val value: T) : B() {
|
||||
override var test: T = value
|
||||
}
|
||||
|
||||
open class F<T : Number>(val value: T) {
|
||||
open var rest: T = value
|
||||
}
|
||||
|
||||
class G<E : Double>(val balue: E) : F<E>(balue) {
|
||||
override var rest: E = balue
|
||||
}
|
||||
|
||||
class H<E : String>(val balue: E) : <!INAPPLICABLE_CANDIDATE!>F<E><!>(balue) {
|
||||
override var rest: E = balue // no report because of INAPPLICABLE_CANDIDATE
|
||||
}
|
||||
|
||||
class M<E : String>(val balue: E) : F<Double>(3.14) {
|
||||
override var rest: <!VAR_TYPE_MISMATCH_ON_OVERRIDE!>E<!> = balue
|
||||
}
|
||||
Vendored
+106
@@ -0,0 +1,106 @@
|
||||
FILE: propertyTypeMismatchOnOverride.kt
|
||||
public open class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open var test: R|kotlin/Number| = Int(10)
|
||||
public get(): R|kotlin/Number|
|
||||
public set(value: R|kotlin/Number|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public open class B : R|A| {
|
||||
public constructor(): R|B| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public open override var test: R|kotlin/Double| = Double(20.0)
|
||||
public get(): R|kotlin/Double|
|
||||
public set(value: R|kotlin/Double|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final class C : R|A| {
|
||||
public constructor(): R|C| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public final override var test: R|kotlin/String| = String(Test)
|
||||
public get(): R|kotlin/String|
|
||||
public set(value: R|kotlin/String|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public open class D : R|B| {
|
||||
public constructor(): R|D| {
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
public open override var test: R|kotlin/Char| = Char(10)
|
||||
public get(): R|kotlin/Char|
|
||||
public set(value: R|kotlin/Char|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final class E<T : R|kotlin/Double|> : R|B| {
|
||||
public constructor<T : R|kotlin/Double|>(value: R|T|): R|E<T>| {
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
public final val value: R|T| = R|<local>/value|
|
||||
public get(): R|T|
|
||||
|
||||
public final override var test: R|T| = R|<local>/value|
|
||||
public get(): R|T|
|
||||
public set(value: R|T|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public open class F<T : R|kotlin/Number|> : R|kotlin/Any| {
|
||||
public constructor<T : R|kotlin/Number|>(value: R|T|): R|F<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val value: R|T| = R|<local>/value|
|
||||
public get(): R|T|
|
||||
|
||||
public open var rest: R|T| = R|<local>/value|
|
||||
public get(): R|T|
|
||||
public set(value: R|T|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final class G<E : R|kotlin/Double|> : R|F<E>| {
|
||||
public constructor<E : R|kotlin/Double|>(balue: R|E|): R|G<E>| {
|
||||
super<R|F<E>|>(R|<local>/balue|)
|
||||
}
|
||||
|
||||
public final val balue: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
|
||||
public final override var rest: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
public set(value: R|E|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final class H<E : R|kotlin/String|> : R|F<E>| {
|
||||
public constructor<E : R|kotlin/String|>(balue: R|E|): R|H<E>| {
|
||||
super<R|F<E>|>(R|<local>/balue|)
|
||||
}
|
||||
|
||||
public final val balue: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
|
||||
public final override var rest: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
public set(value: R|E|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final class M<E : R|kotlin/String|> : R|F<kotlin/Double>| {
|
||||
public constructor<E : R|kotlin/String|>(balue: R|E|): R|M<E>| {
|
||||
super<R|F<kotlin/Double>|>(Double(3.14))
|
||||
}
|
||||
|
||||
public final val balue: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
|
||||
public final override var rest: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
public set(value: R|E|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
open class A {
|
||||
open fun test(): Number = 10
|
||||
}
|
||||
|
||||
open class B : A {
|
||||
override fun test(): Double = 20.0
|
||||
fun test(x: Int) = x
|
||||
}
|
||||
|
||||
class C() : A() {
|
||||
override fun test(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>String<!> = "Test"
|
||||
}
|
||||
|
||||
open class D() : B() {
|
||||
override fun test(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Char<!> = '\n'
|
||||
}
|
||||
|
||||
class E<T : Double>(val value: T) : B() {
|
||||
override fun test(): T = value
|
||||
}
|
||||
|
||||
open class F<T : Number>(val value: T) {
|
||||
open fun rest(): T = value
|
||||
}
|
||||
|
||||
class G<E : Double>(val balue: E) : F<E>(balue) {
|
||||
override fun rest(): E = balue
|
||||
}
|
||||
|
||||
class H<E : String>(val balue: E) : <!INAPPLICABLE_CANDIDATE!>F<E><!>(balue) {
|
||||
override fun rest(): E = balue // no report because of INAPPLICABLE_CANDIDATE
|
||||
}
|
||||
|
||||
class M<E : String>(val balue: E) : F<Double>(3.14) {
|
||||
override fun rest(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>E<!> = balue
|
||||
}
|
||||
|
||||
open class X
|
||||
open class Y() : X()
|
||||
open class Z() : Y()
|
||||
open class W() : Z()
|
||||
|
||||
open class V {
|
||||
open fun hello(): X = X()
|
||||
}
|
||||
|
||||
open class L() : V()
|
||||
|
||||
open class Q() : L()
|
||||
|
||||
open class S() : Q() {
|
||||
override fun hello(): W = W()
|
||||
}
|
||||
|
||||
open class J() : S() {
|
||||
override fun hello(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Z<!> = Z()
|
||||
}
|
||||
|
||||
open class Base<T : X, Z : T> {
|
||||
open fun kek(): Z = Z()
|
||||
}
|
||||
|
||||
open class GoodDerrived : Base<Y, W>() {
|
||||
override fun kek(): W = W()
|
||||
}
|
||||
|
||||
open class BadDerrived : Base<Y, W>() {
|
||||
override fun kek(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>String<!> = "test"
|
||||
}
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
FILE: returnTypeMismatchOnOverride.kt
|
||||
public open class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open fun test(): R|kotlin/Number| {
|
||||
^test Int(10)
|
||||
}
|
||||
|
||||
}
|
||||
public open class B : R|A| {
|
||||
public constructor(): R|B| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public open override fun test(): R|kotlin/Double| {
|
||||
^test Double(20.0)
|
||||
}
|
||||
|
||||
public final fun test(x: R|kotlin/Int|): R|kotlin/Int| {
|
||||
^test R|<local>/x|
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|A| {
|
||||
public constructor(): R|C| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public final override fun test(): R|kotlin/String| {
|
||||
^test String(Test)
|
||||
}
|
||||
|
||||
}
|
||||
public open class D : R|B| {
|
||||
public constructor(): R|D| {
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
public open override fun test(): R|kotlin/Char| {
|
||||
^test Char(10)
|
||||
}
|
||||
|
||||
}
|
||||
public final class E<T : R|kotlin/Double|> : R|B| {
|
||||
public constructor<T : R|kotlin/Double|>(value: R|T|): R|E<T>| {
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
public final val value: R|T| = R|<local>/value|
|
||||
public get(): R|T|
|
||||
|
||||
public final override fun test(): R|T| {
|
||||
^test this@R|/E|.R|/E.value|
|
||||
}
|
||||
|
||||
}
|
||||
public open class F<T : R|kotlin/Number|> : R|kotlin/Any| {
|
||||
public constructor<T : R|kotlin/Number|>(value: R|T|): R|F<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val value: R|T| = R|<local>/value|
|
||||
public get(): R|T|
|
||||
|
||||
public open fun rest(): R|T| {
|
||||
^rest this@R|/F|.R|/F.value|
|
||||
}
|
||||
|
||||
}
|
||||
public final class G<E : R|kotlin/Double|> : R|F<E>| {
|
||||
public constructor<E : R|kotlin/Double|>(balue: R|E|): R|G<E>| {
|
||||
super<R|F<E>|>(R|<local>/balue|)
|
||||
}
|
||||
|
||||
public final val balue: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
|
||||
public final override fun rest(): R|E| {
|
||||
^rest this@R|/G|.R|/G.balue|
|
||||
}
|
||||
|
||||
}
|
||||
public final class H<E : R|kotlin/String|> : R|F<E>| {
|
||||
public constructor<E : R|kotlin/String|>(balue: R|E|): R|H<E>| {
|
||||
super<R|F<E>|>(R|<local>/balue|)
|
||||
}
|
||||
|
||||
public final val balue: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
|
||||
public final override fun rest(): R|E| {
|
||||
^rest this@R|/H|.R|/H.balue|
|
||||
}
|
||||
|
||||
}
|
||||
public final class M<E : R|kotlin/String|> : R|F<kotlin/Double>| {
|
||||
public constructor<E : R|kotlin/String|>(balue: R|E|): R|M<E>| {
|
||||
super<R|F<kotlin/Double>|>(Double(3.14))
|
||||
}
|
||||
|
||||
public final val balue: R|E| = R|<local>/balue|
|
||||
public get(): R|E|
|
||||
|
||||
public final override fun rest(): R|E| {
|
||||
^rest this@R|/M|.R|/M.balue|
|
||||
}
|
||||
|
||||
}
|
||||
public open class X : R|kotlin/Any| {
|
||||
public constructor(): R|X| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public open class Y : R|X| {
|
||||
public constructor(): R|Y| {
|
||||
super<R|X|>()
|
||||
}
|
||||
|
||||
}
|
||||
public open class Z : R|Y| {
|
||||
public constructor(): R|Z| {
|
||||
super<R|Y|>()
|
||||
}
|
||||
|
||||
}
|
||||
public open class W : R|Z| {
|
||||
public constructor(): R|W| {
|
||||
super<R|Z|>()
|
||||
}
|
||||
|
||||
}
|
||||
public open class V : R|kotlin/Any| {
|
||||
public constructor(): R|V| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open fun hello(): R|X| {
|
||||
^hello R|/X.X|()
|
||||
}
|
||||
|
||||
}
|
||||
public open class L : R|V| {
|
||||
public constructor(): R|L| {
|
||||
super<R|V|>()
|
||||
}
|
||||
|
||||
}
|
||||
public open class Q : R|L| {
|
||||
public constructor(): R|Q| {
|
||||
super<R|L|>()
|
||||
}
|
||||
|
||||
}
|
||||
public open class S : R|Q| {
|
||||
public constructor(): R|S| {
|
||||
super<R|Q|>()
|
||||
}
|
||||
|
||||
public open override fun hello(): R|W| {
|
||||
^hello R|/W.W|()
|
||||
}
|
||||
|
||||
}
|
||||
public open class J : R|S| {
|
||||
public constructor(): R|J| {
|
||||
super<R|S|>()
|
||||
}
|
||||
|
||||
public open override fun hello(): R|Z| {
|
||||
^hello R|/Z.Z|()
|
||||
}
|
||||
|
||||
}
|
||||
public open class Base<T : R|X|, Z : R|T|> : R|kotlin/Any| {
|
||||
public constructor<T : R|X|, Z : R|T|>(): R|Base<T, Z>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open fun kek(): R|Z| {
|
||||
^kek R|/Z.Z|()
|
||||
}
|
||||
|
||||
}
|
||||
public open class GoodDerrived : R|Base<Y, W>| {
|
||||
public constructor(): R|GoodDerrived| {
|
||||
super<R|Base<Y, W>|>()
|
||||
}
|
||||
|
||||
public open override fun kek(): R|W| {
|
||||
^kek R|/W.W|()
|
||||
}
|
||||
|
||||
}
|
||||
public open class BadDerrived : R|Base<Y, W>| {
|
||||
public constructor(): R|BadDerrived| {
|
||||
super<R|Base<Y, W>|>()
|
||||
}
|
||||
|
||||
public open override fun kek(): R|kotlin/String| {
|
||||
^kek String(test)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user