Change Thanks to Derek pointing to the critical part of the error message, I was able to extract the critical part a little more, and it looks like Existential types. If I understand correctly Β§3.2.10 Existential quantification over values ββin a language rule, then val m: Map[x.type#S, x.type#S] forSome { val x: T } is short for val m: Map[t#S, t#S] forSome { type t <: T with Singleton } . However, in the code below, they behave differently.
trait Type { type S } class Concrete extends Type { type S = Double } trait BaseWorks { type T <: Type val m: t
Clearing BaseWorks works, and refining BaseError results in an error: overriding value m in trait BaseError of type Error.this.xS forSome { val x: => Error.this.T }; value m has incompatible type error: overriding value m in trait BaseError of type Error.this.xS forSome { val x: => Error.this.T }; value m has incompatible type . Am I misinterpreting Β§3.2.10?
Original post . In the following Scala code snippet, the compiler (2.9.0.1) generates an error saying that the f2 method does not undo anything in Derived .
abstract trait Type { type T1 type T2 type P = (T1, T2) } class ConcreteType extends Type { type T1 = Double type T2 = Double } abstract class Base { type T <: Type type TP = T
On the other hand, overriding the function f3 with the same signature as in the code works. I would expect both functions to behave the same. Why is this not so?
source share