Created
February 19, 2018 14:22
-
-
Save FredDeschenes/83cee779fcc3fb1bb63c8fabfed28806 to your computer and use it in GitHub Desktop.
Kotlin extension shadowing bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.reflect.KClass | |
fun main(args: Array<String>) { | |
UsesKClass.theFun(TestClass::class) //UsesKClass :: KClass | |
UsesTheAny.theFun(TestClass::class) //UsesTheAny :: Any | |
} | |
class TestClass | |
object UsesKClass { | |
fun theFun(klazz: KClass<*>) { | |
println("UsesKClass :: KClass") | |
} | |
fun theFun(klazz: Any) { | |
println("UsesKClass :: Any") | |
} | |
} | |
object UsesTheAny { | |
fun theFun(klazz: Any) { | |
println("UsesTheAny :: Any") | |
} | |
} | |
// Warning :: Extension is shadowed by a member: public final fun theFun(klazz: Any): Unit | |
fun UsesTheAny.theFun(klazz: KClass<*>) { | |
println("UsesTheAny :: KClass") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment