Davide Giuseppe Farella
06/07/2020, 6:46 AMclass MyClass<T>
MyClass<String?>().myExtension() // -> OK
MyClass<String >().myExtension() // -> Does not compile?
Derek Peirce
06/07/2020, 8:06 AMMyClass<String?>.myExtension()
should not be callable on a MyClass<String>
object, unless you're using covariance. Or are you actually asking about MyClass<String>?
?Davide Giuseppe Farella
06/07/2020, 8:11 AMinterface Asserter<out T> {
val actual: T?
}
and
infix fun <T : Any?> Asserter<T>.`is`(_null: Null) =
assertNull(actual)
and I’m expecting to NOT be able to call something like
`assert that "Hello" is
Null`
( where assert that "Hello"
is Asserter<String
)Zach Klippenstein (he/him) [MOD]
06/07/2020, 2:14 PMAny
) and give it a deprecated annotation with the error level (the coroutine library uses this trick to "capture" invalid calls and suggest alternatives), since the compiler will always select the most specific overload of a method.
You also don't need the Any?
bound in this code, it's the implicit upper bound if none is specified because it's the top type.Davide Giuseppe Farella
06/07/2020, 3:37 PM