diff options
author | Martin Odersky <odersky@gmail.com> | 2014-12-15 17:48:49 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-12-15 18:08:32 +0100 |
commit | a928d99799be8f9ab567b5aca5e21cdd861fb5df (patch) | |
tree | c1d9b2e76a19d9ddd4f6843e20993bb5b4eda8eb /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 4494c16758836296bdcc6567b3042ae3d3d02857 (diff) | |
download | dotty-a928d99799be8f9ab567b5aca5e21cdd861fb5df.tar.gz dotty-a928d99799be8f9ab567b5aca5e21cdd861fb5df.tar.bz2 dotty-a928d99799be8f9ab567b5aca5e21cdd861fb5df.zip |
Fix typechecking rules for Binds of type trees.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index f6027165b..10bc59a1a 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -776,7 +776,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedAppliedTypeTree(tree: untpd.AppliedTypeTree)(implicit ctx: Context): AppliedTypeTree = track("typedAppliedTypeTree") { val tpt1 = typed(tree.tpt) - val args1 = tree.args mapconserve (typed(_)) + val argPts = + if (ctx.mode is Mode.Pattern) tpt1.tpe.typeParams.map(_.info) + else tree.args.map(_ => WildcardType) + val args1 = tree.args.zipWithConserve(argPts)(typed(_, _)).asInstanceOf[List[Tree]] // check that arguments conform to bounds is done in phase FirstTransform assignType(cpy.AppliedTypeTree(tree)(tpt1, args1), tpt1, args1) } @@ -798,7 +801,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedBind(tree: untpd.Bind, pt: Type)(implicit ctx: Context): Bind = track("typedBind") { val body1 = typed(tree.body, pt) typr.println(i"typed bind $tree pt = $pt bodytpe = ${body1.tpe}") - val sym = ctx.newSymbol(ctx.owner, tree.name.asTermName, EmptyFlags, body1.tpe, coord = tree.pos) + val sym = ctx.newSymbol(ctx.owner, tree.name, EmptyFlags, body1.tpe, coord = tree.pos) assignType(cpy.Bind(tree)(tree.name, body1), sym) } @@ -1339,7 +1342,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } case _ => if (ctx.mode is Mode.Type) - if (tree.tpe <:< pt) tree + if ((ctx.mode is Mode.Pattern) || tree.tpe <:< pt) tree else err.typeMismatch(tree, pt) else adaptNoArgs(wtp) } |