aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-02-17 17:33:19 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-02-17 17:33:19 +0100
commit75dcc47f99cb1bdcdd1aac99be0182ddda3b5a16 (patch)
treec7c0bc9a06f64b74f6ac27b63053fc586c546827 /compiler/src/dotty/tools/dotc/typer/Typer.scala
parent80511914713237de894f896da7397965e52134a7 (diff)
downloaddotty-75dcc47f99cb1bdcdd1aac99be0182ddda3b5a16.tar.gz
dotty-75dcc47f99cb1bdcdd1aac99be0182ddda3b5a16.tar.bz2
dotty-75dcc47f99cb1bdcdd1aac99be0182ddda3b5a16.zip
Fix binding of x @ (e: T) in ClassTag-based patmat
We cannot assume that the untyped rhs of the bind is a `Typed` tree, with extractors it might be an `Apply` node, and in general it might also be a `Parens` node.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Typer.scala12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala
index 820044b8e..498fd001b 100644
--- a/compiler/src/dotty/tools/dotc/typer/Typer.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala
@@ -1128,15 +1128,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedBind(tree: untpd.Bind, pt: Type)(implicit ctx: Context): Tree = track("typedBind") {
val pt1 = fullyDefinedType(pt, "pattern variable", tree.pos)
val body1 = typed(tree.body, pt1)
- typr.println(i"typed bind $tree pt = $pt1 bodytpe = ${body1.tpe}")
body1 match {
- case UnApply(fn, Nil, arg :: Nil) if tree.body.isInstanceOf[untpd.Typed] && !body1.tpe.isError =>
- // A typed pattern `x @ (_: T)` with an implicit `ctag: ClassTag[T]`
- // was rewritten to `x @ ctag(_)`.
- // Rewrite further to `ctag(x @ _)`
- assert(fn.symbol.owner == defn.ClassTagClass)
+ case UnApply(fn, Nil, arg :: Nil) if fn.symbol.owner == defn.ClassTagClass && !body1.tpe.isError =>
+ // A typed pattern `x @ (e: T)` with an implicit `ctag: ClassTag[T]`
+ // was rewritten to `x @ ctag(e)` by `tryWithClassTag`.
+ // Rewrite further to `ctag(x @ e)`
tpd.cpy.UnApply(body1)(fn, Nil,
- typed(untpd.Bind(tree.name, arg).withPos(tree.pos), arg.tpe) :: Nil)
+ typed(untpd.Bind(tree.name, untpd.TypedSplice(arg)).withPos(tree.pos), arg.tpe) :: Nil)
case _ =>
val sym = newPatternBoundSym(tree.name, body1.tpe, tree.pos)
assignType(cpy.Bind(tree)(tree.name, body1), sym)