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
Here is a minimized example showing a small difference between Dotty and scalac handling of the "Aux pattern". The issue is that when asking for an implicit Tagged.Aux[T, _] instead of Tagged[T], Dotty won't consider the companion object of T as part of the its implicit scopes.
traitTagged[T]
objectTagged {
typeAux[T, UNUSED] =Tagged[T]
}
traitFun[R] {
typeOut
}
objectFunextendsFun0 {
// In Dotty there is a difference between asking for Tagged.Aux[T, Int]// and asking for Tagged[T]. In the former case the companion of T is// not considered as a valid scope during implicit search. In scalac// both cases are treated equally.implicitdeftagged[T](implicitt: Tagged.Aux[T, Int]):Fun[T] { typeOut=Int } =???
}
traitFun0 {
implicitdefdefault[T]:Fun[T] { typeOut=String } =???
}
objectFunDemoextendsApp {
caseclassA(x: Int, y: String)
objectA {
implicitvaltag:Tagged[A] =???
}
// Precise version of implicitly that keeps type membersdefthe[T<:AnyRef](implicitev: T): ev.type= ev
valadhl= the[Fun[A]]
// Compiles in scalac: the tagged case wins the implicit search using A.tag// Does not compile in Dotty: because of Tagged.Aux[T, _] the companion// object of T is not explored during the search,// it fallbacks to default (type Out = String)
identity[Fun[A] { typeOut=Int }](adhl)
}
The text was updated successfully, but these errors were encountered:
Here is a minimized example showing a small difference between Dotty and scalac handling of the "Aux pattern". The issue is that when asking for an
implicit Tagged.Aux[T, _]
instead ofTagged[T]
, Dotty won't consider the companion object ofT
as part of the its implicit scopes.The text was updated successfully, but these errors were encountered: