Here is a simple example:
trait Proposition[T] {
type Repr = T
}
trait Scope {
type OUT
type Consequent = Proposition[_ <: OUT]
abstract class Proof[-I, +P <: Consequent] {
final def instanceFor(v: I): P#Repr = ???
final def apply(v: I): P#Repr = instanceFor(v)
}
}
This gives the compilation error:
[Error] ....scala:44: type mismatch;
found : _$1(in type Consequent)
required: (some other)_$1(in type Consequent)
Where does this (some other)
come from? Is it a compiler bug caused by a clear rule of type selection (which should be theoretically solved in scala 3)?
UPDATE 1 Sorry I just realised that P#Repr
should not be called type selection, which should only refers to val p: P;p.Repr
, now it added even more confusion because:
I don't even know the name of this grammar, yet I kept using it for a long time
It is not even defined in DOT calculus. So scala 3 support is questionable