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
For some reason, the .apply method on ComputesApplication1 is determined to yield Computes[Nothing] instead of Computes[T] as the signature dictates.
While trying to minimise my example, here are some variations I tried:
Removing the : Type implicits prevents the bug from occurring.
Replacing Type with a trait declared trait SomeImplicit[T] does not cause the same issue
Removing only the : Type in the let method changes nothing, while it should fail because the ComputesApplication1 would then be missing an implicit it needs.
Removing the Computes[...] and just leaving Opaque[...] causes what's left to just compile normally
The text was updated successfully, but these errors were encountered:
sealedabstractclassComputes[T]
objectComputes {
typeType[Y]
typeFoo[T] =IntclassComputesApplication1[T:Type](fn : Computes[Foo[T]]) {
defapply() :Computes[T] =???
}
deflet[X:Type](body : Computes[Foo[X]]) :Computes[X] = {
implicitvalx:Type[Nothing] =???// Should not be needed, looked for as ComputesApplication1[Nothing] requires itnewComputesApplication1(body).apply()
}
}
Therefore it has nothing to do with opaque types, the issue is more general.
For ComputesApplication1 we are inferring the bounds Nothing <:< T <:< X and then choose the lower bound as it is the most precise one.
nicolasstucki
changed the title
Unexplainable interaction between opaque types and implicits
Imprecise type inferred with polymorphic type alias
Jun 17, 2019
Trying to compile this code yields an error I can't make sense of:
The error is:
For some reason, the
.apply
method onComputesApplication1
is determined to yieldComputes[Nothing]
instead ofComputes[T]
as the signature dictates.While trying to minimise my example, here are some variations I tried:
: Type
implicits prevents the bug from occurring.Type
with a trait declaredtrait SomeImplicit[T]
does not cause the same issue: Type
in thelet
method changes nothing, while it should fail because theComputesApplication1
would then be missing an implicit it needs.Computes[...]
and just leavingOpaque[...]
causes what's left to just compile normallyThe text was updated successfully, but these errors were encountered: