-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Compiler version
3.7.3
Minimized code
object Test {
def main(args: Array[String]): Unit = {
blub(classOf[Object])
}
def blub[T](a: Class[? <: T]): Unit = println("a")
def blub[T](a: Class[T], ints: Int*): Unit = println("b")
}Output
Ambiguous overload. The overloaded alternatives of method blub in object Test with types
[T](a: Class[T], ints: Int*): Unit
[T](a: Class[? <: T]): Unit
both match arguments ((classOf[Object] : Class[Object]))Expectation
Should run and print a
Reasons this should not be an error
- The same code compiles in Scala 2 and prints
a - If the variadic parameter is replaced with a default parameter, the code compiles in Scala2 and Scala3 and prints
a - The same code works in Java and otherwise it's not possible to call the version that prints
afrom Scala3:
public class TestInJava {
public static void main(String[] args) {
blub(Object.class);
}
public static <T> void blub(Class<? extends T> cls) {
System.out.println("a");
}
public static <T> void blub(Class<T> cls, int ...b) {
System.out.println("b");
}
}unkarjedy, Gedochao, noti0na1 and tanishiking