@@ -940,8 +940,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
940
940
def caseRest (pat : Tree )(implicit ctx : Context ) = {
941
941
val pat1 = indexPattern.transform(pat)
942
942
val guard1 = typedExpr(tree.guard, defn.BooleanType )
943
- val body1 = ensureNoLocalRefs(typedExpr(tree.body, pt), pt, ctx.scope.toList)
944
- .ensureConforms(pt)(originalCtx) // insert a cast if body does not conform to expected type if we disregard gadt bounds
943
+ var body1 = ensureNoLocalRefs(typedExpr(tree.body, pt), pt, ctx.scope.toList)
944
+ if (pt.isValueType) // insert a cast if body does not conform to expected type if we disregard gadt bounds
945
+ body1 = body1.ensureConforms(pt)(originalCtx)
945
946
assignType(cpy.CaseDef (tree)(pat1, guard1, body1), body1)
946
947
}
947
948
@@ -1183,7 +1184,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1183
1184
val pt1 = fullyDefinedType(pt, " pattern variable" , tree.pos)
1184
1185
val body1 = typed(tree.body, pt1)
1185
1186
body1 match {
1186
- case UnApply (fn, Nil , arg :: Nil ) if fn.symbol.owner == defn.ClassTagClass && ! body1.tpe.isError =>
1187
+ case UnApply (fn, Nil , arg :: Nil )
1188
+ if fn.symbol.exists && fn.symbol.owner == defn.ClassTagClass && ! body1.tpe.isError =>
1187
1189
// A typed pattern `x @ (e: T)` with an implicit `ctag: ClassTag[T]`
1188
1190
// was rewritten to `x @ ctag(e)` by `tryWithClassTag`.
1189
1191
// Rewrite further to `ctag(x @ e)`
0 commit comments