I raised Unable to implement trait with member that uses general type projection · Issue #12949 · scala/bug · GitHub but I mistakenly put a question in it which is not allowed and so it was closed.
This fails to compile in Scala 2.13.12:
trait QueryTaggedNode[I] {
type Input = I
}
trait ThinQueryParams[TQuery <: QueryTaggedNode[_]] {
val variables: TQuery#Input
}
object ThinQueryParams {
def apply[TQuery <: QueryTaggedNode[_]](
variables: TQuery#Input,
): ThinQueryParams[TQuery] = {
val _variables = variables
new ThinQueryParams[TQuery] {
override val variables: TQuery#Input = _variables
}
}
}
It fails with:
type mismatch;
found : _variables.type (with underlying type _$2)
required: _$2
type mismatch;
found : this.variables.type (with underlying type _$2)
required: _$2
complaining about the types on both the left and right hand side of the variables
definition.
There is definitely a bug here. Either:
a) It should compile, or
b) It should not compile and the error message should be improved to not be contradictory (there should also only be a single error about the signature being the wrong type instead of the value)
So which is it?