Closed
Description
class A
class B extends A
class Map[T] { def foo(x: T): A = new A }
// This is an overload and not an override
class AnyRefMap[T <: AnyRef] extends Map[T] { def foo(y: T with AnyRef): B = new B }
object Test {
(new AnyRefMap[String]).foo("Hello") // B
(new AnyRefMap[String]: Map[String]).foo("Hello") // A
}
-- Error: tests/allan/Test.scala:32:50 -----------------------------------------
32 |class AnyRefMap[T <: AnyRef] extends Map[T] { def foo(y: T with AnyRef): B = new B }
| ^
| error overriding method foo in class Map of type (x: T): A;
| method foo of type (y: T & AnyRef): B needs `override' modifier
one error found