I am using a library which is written by amazon in scala here
The trait goes like this :
trait Analyzer[S <: State[_], +M <: Metric[_]]
I am trying to make a case object to store some information and an instace of the above Analyzer is a part of it.
case class AnomalyCheckConfigBuilder(anomalyDetectionStrategy: AnomalyDetectionStrategy,
analyzer: Analyzer[_, Metric[_]],
anomalyCheckConfig: Option[AnomalyCheckConfig] = None)
I'm getting the below error :
error: type arguments [_$1,com.amazon.deequ.metrics.Metric[_]] do not conform to trait Analyzer's type parameter bounds [S <: com.amazon.deequ.analyzers.State[_],+M <: com.amazon.deequ.metrics.Metric[_]]
case class AnomalyCheckConfigBuilder(anomalyDetectionStrategy: AnomalyDetectionStrategy,
Not sure, what's the problem here. Does anyone understand this?
The thing is, if you look at the definition of
Statetrait, you will seetrait State[S <: State[S]]which means the type inside the State type argument (named S), MUST be a subtype of State of that type, for instance:trait MyState extends State[MyState]. but using underscore inanalyzer: Analyzer[_(this one), Metric[_]]does not assure the compiler that this type extends State of that type. to make the compile error go away, you can do:which is shorter form of