Closed
Description
Trying to compile this code yields an error I can't make sense of:
package towers.computes
import quoted._
sealed abstract class Computes[T]
object Computes {
opaque type Opaque[T] = Int
implicit class ComputesApplication1[T : Type](fn : Computes[Opaque[T]]) {
def apply[A](arg1 : Computes[A]) : Computes[T] = ???
}
def let[V, T : Type](value : Computes[V], body : Computes[Opaque[T]]) : Computes[T] = body(value)
}
The error is:
[error] -- [E007] Type Mismatch Error: /home/finn/programming/polyparse/src/main/scala/Computes.scala:15:92
[error] 15 | def let[V, T : Type](value : Computes[V], body : Computes[Opaque[T]]) : Computes[T] = body(value)
[error] | ^^^^^^^^^^^
[error] | Found: towers.computes.Computes[Nothing]
[error] | Required: towers.computes.Computes[T]
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 declaredtrait SomeImplicit[T]
does not cause the same issue - Removing only the
: Type
in thelet
method changes nothing, while it should fail because theComputesApplication1
would then be missing an implicit it needs. - Removing the
Computes[...]
and just leavingOpaque[...]
causes what's left to just compile normally
Metadata
Metadata
Assignees
Labels
No labels