You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala.tasty.Reflection provides given instances of ClassTag to be able to pattern match (ClassTag.unapply).
But if they are used those as ClassTag (i.e. for arrays) we hit an unsoundness when type types in Reflection are implemented with the same class.
The solution is not to give implicit ClassTags for those types, or only give one for the root type (Tree, Type, Position, ...).
Therefore the ClassTag concept should be separate from the type testing logic (see #7555).
Here is a minimal self contained example of how this unsoundness can be triggered
packagex@main defFoo= {
valrefl:Refl=newReflImplimportrefl._valarr=Array[refl.Tree]()
arr matchcasearr: Array[refl.Term] =>thrownewException() // some elements of the array may to be refl.Termcase _ =>// ok
}
traitRefl {
typeTreetypeTerm<:TreedeftreeCT: scala.reflect.ClassTag[Tree]
deftermCT: scala.reflect.ClassTag[Term]
givenscala.reflect.ClassTag[Tree] = treeCT
givenscala.reflect.ClassTag[Term] = termCT
}
objectReflImpl {
classTreedeftreeCT: scala.reflect.ClassTag[Tree] = summon[scala.reflect.ClassTag[Tree]]
}
classReflImplextendsRefl {
typeTree=ReflImpl.TreetypeTerm=ReflImpl.TreedeftreeCT: scala.reflect.ClassTag[Tree] =ReflImpl.treeCT
deftermCT: scala.reflect.ClassTag[Term] =ReflImpl.treeCT
}
The text was updated successfully, but these errors were encountered:
scala.tasty.Reflection
provides given instances ofClassTag
to be able to pattern match (ClassTag.unapply
).But if they are used those as
ClassTag
(i.e. for arrays) we hit an unsoundness when type types inReflection
are implemented with the same class.The solution is not to give implicit
ClassTag
s for those types, or only give one for the root type (Tree
,Type
,Position
, ...).Therefore the
ClassTag
concept should be separate from the type testing logic (see #7555).Here is a minimal self contained example of how this unsoundness can be triggered
The text was updated successfully, but these errors were encountered: