-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#7966Closed
Copy link
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)jdk11
Milestone
Description
Java 8:
scala> import java.util.Properties
import java.util.Properties
scala> new Properties().putAll(new Properties)
Java 9:
scala> import java.util.Properties
import java.util.Properties
scala> new Properties().putAll(new Properties)
<console>:13: error: ambiguous reference to overloaded definition,
both method putAll in class Properties of type (x$1: java.util.Map[_, _])Unit
and method putAll in class Hashtable of type (x$1: java.util.Map[_ <: Object, _ <: Object])Unit
match argument types (java.util.Properties)
new Properties().putAll(new Properties)
The reason is that the following override was added in Java 9 in order to use a ConcurrentHashMap as the underlying implementation:
@Override
public synchronized void putAll(Map<?, ?> t) {
map.putAll(t);
}
scalac seems to think it's an overload instead of an override. The Hashtable method is defined as (K = Object and V = Object):
public synchronized void putAll(Map<? extends K, ? extends V> t) {
for (Map.Entry<? extends K, ? extends V> e : t.entrySet())
put(e.getKey(), e.getValue());
}
I found this while trying to compile Apache Kafka with Java 9.
Is it worth doing anything about this apart from documenting it somewhere?
namannigam-zz, jvican, Milyardo, tombentley, bunadmitrii and 6 more
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)jdk11