Giovanni Azua Giovanni Azua -3 years ago 114
Scala Question

Warning: non-variable type argument in type pattern is unchecked since it is eliminated by erasure

I'm using Scala 2.10.6 due to corporate restrictions. How can I get rid of the warning:

warning: non-variable type argument Market in type pattern () => Market is unchecked
since it is eliminated by erasure


in the following definition:

case (payoff: Payoff, mktFun: (() => Market)) => {
val mkt = mktFun()
// ...
}

Answer Source

You can, for instance, make a dedicated datatype case class Foo(p: PayOff, f: () => Market) which you can use as a pattern, instead of a generic tuple.

case Foo(payoff, mktFun) => {
    val mkt = mktFun()
    // ...
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download