Reputation: 14309
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()
// ...
}
Upvotes: 1
Views: 1635
Reputation: 14309
A very simple solution that works is defining a custom function type:
type MktFun = () => Market
and then:
case (payoff: Payoff, mktFun: MktFun) => {
val mkt = mktFun()
// ...
}
and I don't get the warning anymore.
Upvotes: 0
Reputation: 15086
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()
// ...
}
Upvotes: 2