open abstract class ParentTest<in T> { abstract fun hello(other: T): Int }
open abstract class MyAB<T> : ParentTest<T>() {
}
class MyImp1 : MyAB<Double>() { override fun hello(other: Double): Int { // TODO("not implemented") //To change body of created functions use File | Settings | File Templates. println("hello,you call ") return 1; }
}
fun demo(x: ParentTest<Double>) { x.hello(1.0) // 1.0 has type Double, which is a subtype of Number // Thus, we can assign x to a variable of type ParentTest<Double> val y: ParentTest<Double> = x // OK! }
/* fun demo1(x: ParentTest<Int>) { x.hello(1.0) // 1.0 has type Double, which is a subtype of Number // Thus, we can assign x to a variable of type ParentTest<Double> val y: ParentTest<Double> = x // OK! } */
demo(MyImp1()); // demo1(MyImp1());//err musct int