Cast arguments to proper types when generating delegates
Also minor refactoring in a couple places to adopt this style
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
trait A<T> {
|
||||
fun foo(t: T): String
|
||||
}
|
||||
|
||||
class Derived(a: A<Int>) : A<Int> by a
|
||||
|
||||
fun box(): String {
|
||||
val o = object : A<Int> {
|
||||
override fun foo(t: Int) = if (t == 42) "OK" else "Fail $t"
|
||||
}
|
||||
return Derived(o).foo(42)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
trait A<T: Number> {
|
||||
fun foo(t: T): String
|
||||
}
|
||||
|
||||
class Derived(a: A<Int>) : A<Int> by a
|
||||
|
||||
fun box(): String {
|
||||
val o = object : A<Int> {
|
||||
override fun foo(t: Int) = if (t == 42) "OK" else "Fail $t"
|
||||
}
|
||||
return Derived(o).foo(42)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
trait A<T, U> {
|
||||
fun foo(t: T, u: U): String
|
||||
}
|
||||
|
||||
class Derived(a: A<Long, Int>) : A<Long, Int> by a
|
||||
|
||||
fun box(): String {
|
||||
val o = object : A<Long, Int> {
|
||||
override fun foo(t: Long, u: Int) = if (t == u.toLong()) "OK" else "Fail $t $u"
|
||||
}
|
||||
return Derived(o).foo(42, 42)
|
||||
}
|
||||
Reference in New Issue
Block a user