scala - Trait does not conform with type parameter bounds -
i having issues types. in case have 2 traits base methods, , 1 of them depends on other. after have 2 implementations them. have idea wrong here?
the compiler saying:
type arguments [impldefinition,impldto,impldtoidentifier] not conform trait childoperations's type parameter bounds [c <: types.baset[a,i],a <: types.idobj[i],i <: iidentifier] [error] class imploperations extends parent2(new impldefinition) childoperations[impldefinition, impldto, impldtoidentifier] {
the code:
/* * generic implementation */ object types { type idobj[i <: iidentifier] = anyref {def id: i} type baset[a, <: iidentifier] = parent1[a] { def id: foo[i] } } trait iidentifier extends { def id: long override def tostring = id.tostring } class parent1[a](a: string) class foo[a](a: string) trait childdefinition[a <: types.idobj[i], <: iidentifier] { self: parent1[a] => def id(a: a): foo[i] } class parent2[a](a: a) trait childoperations[c <: types.baset[a, i], <: types.idobj[i], <: iidentifier] { self: parent2[c] => def get(identifier: i): option[a] } /* * concrete implementation */ case class impldtoidentifier(id: long) extends iidentifier case class impldto(id: impldtoidentifier, name: string) class impldefinition extends parent1[impldto]("value") childdefinition[impldto, impldtoidentifier] { override def id(a: impldto): foo[impldtoidentifier] = ??? } class imploperations extends parent2(new impldefinition) childoperations[impldefinition, impldto, impldtoidentifier] { self => override def get(identifier: impldtoidentifier): option[impldto] = ??? // here use id method impldefinition }
the problem seems signature of id
def in impldefinition
. types.baset
asks def id: foo[i]
impldefinition
provides def id(a: impldto): foo[impldtoidentifier]
if add def id:foo[impldtoidentifier] = ???
impldefinition
class things compile:
class impldefinition extends parent1[impldto]("value") childdefinition[impldto, impldtoidentifier] { def id:foo[impldtoidentifier] = ??? override def id(a: impldto): foo[impldtoidentifier] = ??? }
Comments
Post a Comment