推断类型参数 [_$1] 不符合方法类型参数边界
我有一个案例类:
case class AnomalyCheckConfigBuilder[S <: State[S]](anomalyDetectionStrategy: AnomalyDetectionStrategy,
analyzer: Analyzer[S, Metric[Double]],
anomalyCheckConfig: Option[AnomalyCheckConfig] = None)
我有一个函数,它以 Seq 的形式返回上述案例类对象的集合。
val anomalyCheckConfig : Seq[AnomalyCheckConfigBuilder[_]] = jobConfig.validate.get.getAnomalyCheckConfigBuilder
我将上面列表中的对象添加到签名如下的另一个方法中:
def addAnomalyCheck[S <: State[S]](
anomalyDetectionStrategy: AnomalyDetectionStrategy,
analyzer: Analyzer[S, Metric[Double]],
anomalyCheckConfig: Option[AnomalyCheckConfig] = None)
: this.type
我正在执行以下操作:
anomalyCheckConfig.foreach(x=>{
verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
})
其中 VerificationSuite 是来自 Deeque
错误我得到的上面的代码是:
error: inferred type arguments [_$1] do not conform to method addAnomalyCheck's type parameter bounds [S <: com.amazon.deequ.analyzers.State[S]]
[ERROR] verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
error: type mismatch;
[ERROR] found : com.amazon.deequ.analyzers.Analyzer[_$1,com.amazon.deequ.metrics.Metric[Double]]
[ERROR] required: com.amazon.deequ.analyzers.Analyzer[S,com.amazon.deequ.metrics.Metric[Double]]
[ERROR] verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
代码编译时失败,scala 无法理解状态,我无法理解 _$1
来自哪里。希望对此有一些意见
I have a case class :
case class AnomalyCheckConfigBuilder[S <: State[S]](anomalyDetectionStrategy: AnomalyDetectionStrategy,
analyzer: Analyzer[S, Metric[Double]],
anomalyCheckConfig: Option[AnomalyCheckConfig] = None)
And i have a function which returns a collection of the above case class objects in the form of a Seq.
val anomalyCheckConfig : Seq[AnomalyCheckConfigBuilder[_]] = jobConfig.validate.get.getAnomalyCheckConfigBuilder
I am adding the objects from the above list to another method who's signature is below :
def addAnomalyCheck[S <: State[S]](
anomalyDetectionStrategy: AnomalyDetectionStrategy,
analyzer: Analyzer[S, Metric[Double]],
anomalyCheckConfig: Option[AnomalyCheckConfig] = None)
: this.type
I am doing the below operation :
anomalyCheckConfig.foreach(x=>{
verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
})
Where verificationSuite is a opensource code from Deeque
Error i am getting on the above code is :
error: inferred type arguments [_$1] do not conform to method addAnomalyCheck's type parameter bounds [S <: com.amazon.deequ.analyzers.State[S]]
[ERROR] verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
error: type mismatch;
[ERROR] found : com.amazon.deequ.analyzers.Analyzer[_$1,com.amazon.deequ.metrics.Metric[Double]]
[ERROR] required: com.amazon.deequ.analyzers.Analyzer[S,com.amazon.deequ.metrics.Metric[Double]]
[ERROR] verificationSuite = verificationSuite.addAnomalyCheck(x.anomalyDetectionStrategy,x.analyzer,x.anomalyCheckConfig)
The code fails on compile time and scala is unable to understand the state, and i am unable to understand where is _$1
coming from. Would appreciate some inputs on thiss
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这清楚地表明 Scala 需要您提供
'S'
的实例,它是State
类的子类型。您需要做的是:
您还需要将其包装在一个函数下,该函数接受
S
作为State
的子类型This clearly says that Scala needs you to provide an instance of
'S'
which is a subtype ofState
class.What you need to do is :
Also you need to wrap this under a function which accepts
S
as a subtype ofState