Closed
Description
object test {
class Foo[a](val arg : a)
object Foo {
def unapply [a](m : Foo[a]) = Some (m.arg)
}
def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }}
// Unapply node here will have type argument [a] instantiated to scala.Nothing:
// UnApply(TypeApply(Select(Ident(Foo),unapply),List(TypeTree[TypeVar(PolyParam(a) -> TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing))])),List(),List(Bind(x,Ident(_))))
// but the type of the UnApply node itself is correct: RefinedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,<empty>)),test$)),Foo), test$$Foo$$a, TypeAlias(TypeRef(NoPrefix,a)))
}
Given such types the rewriting from UnApply(fun,Nil,_)
to
val result = fun(matchSelector)
cannot be applied as sel
has type not matching fun
(because fun was instantiated with wrong type arguments)
Metadata
Metadata
Assignees
Labels
No labels