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
where different constructors, such as `IntLit` and `Fun`, pass different type argument to the super trait. Hence, typechecking a pattern match on `v: Exp[T]` requires special care: for instance, if `v = IntLit(5)` then the typechecker must realize that `T` must be `Int`. This enables writing a typed interpreter `eval[T](e: Exp[T]): T`, where say the `IntLit` branch can return an `Int`:
133
+
where different constructors, such as `IntLit` and `Fun`, pass different type argument to the super
134
+
trait. Hence, typechecking a pattern match on `v: Exp[T]` requires special care. For instance, if
135
+
`v = IntLit(5)` then the typechecker must realize that `T` must be `Int`. This enables writing a
136
+
typed interpreter `eval[T](e: Exp[T]): T`, where say the `IntLit` branch can return an `Int`:
135
137
136
138
```scala
137
139
objectInterpreter {
@@ -140,17 +142,12 @@ object Interpreter {
140
142
n
141
143
142
144
casegl: GenLit[_] =>// Here in fact gl: GenLit[T]
143
-
144
-
// the next line was incorrectly allowed before the fix to https://github.com/lampepfl/dotty/issues/1754:
145
-
//val gl1: GenLit[Nothing] = gl
145
+
// the next line was incorrectly allowed before the fix to https://github.com/lampepfl/dotty/issues/1754
146
+
// val gl1: GenLit[Nothing] = gl
146
147
147
148
gl.t
148
149
149
-
casePlus(e1, e2) =>
150
-
// Here T = Int and e1, e2: Exp[Int]
151
-
eval(e1) + eval(e2)
152
-
153
-
// The next cases triggered warnings before the fix to
150
+
// The next cases triggered spurious warnings before the fix to
0 commit comments