Closed
Description
Minimized code
class One[A]{}
def test[A](a: Class[A]) = println(a)
def test[A](as: List[A]) = println(as)
def tost[A](a: Class[A]) = println(a)
@main def main() = {
val one: One[_] = new One()
test(one.getClass()) //this fails
val cls = one.getClass()
test(cls) //this is ok
tost(one.getClass()) //this is also ok
}
Output
None of the overloaded alternatives of method test with types
[A](as: List[A]): Unit
[A](a: Class[A]): Unit
match arguments (Class[? <: One[?]])
Expectation
of
test(one.getClass())
test(cls)
tost(one.getClass())
either all of them compile, or all of them fail. They all compile in scala 2.