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
-- [E007] TypeMismatchError:Test.scala:12:35--------------------------------12|caseTyping(expr, `to`) =>Right(expr)
|^^^^|Found: (expr : TypedExpr[A])
|Required:TypedExpr[B]
||where: A is a typein method cast with bounds <:Type|B is a typein method cast with bounds <:Type|| longer explanation available when compiling with`-explain`
Expectation
I would expect the compiler to understand that:
to is equal to repr, so they must be of the same type.
this implies that A and B are the same type.
which implies that expr is a legal TypedExpr[B].
This might be an unreasonable expectation on my part, but I think it's born out by the fact that the following works flawlessly (keeping the same Type and TypedExpr:
With that code, the compiler seems perfectly happy to concluse that A and B are the same type and expr is a valid TypedExpr[B].
The only difference, as far as I understand, is that TypeRepr is indexed on Type rather than being a Type directly, but I'm not sure what additional information / confidence this gives the compiler.
The text was updated successfully, but these errors were encountered:
Compiler version
Minimized code
Output
Expectation
I would expect the compiler to understand that:
to
is equal torepr
, so they must be of the same type.A
andB
are the same type.expr
is a legalTypedExpr[B]
.This might be an unreasonable expectation on my part, but I think it's born out by the fact that the following works flawlessly (keeping the same
Type
andTypedExpr
:With that code, the compiler seems perfectly happy to concluse that
A
andB
are the same type andexpr
is a validTypedExpr[B]
.The only difference, as far as I understand, is that
TypeRepr
is indexed onType
rather than being aType
directly, but I'm not sure what additional information / confidence this gives the compiler.The text was updated successfully, but these errors were encountered: