diff options
author | Dmitry Petrashko <dark@d-d.me> | 2014-12-16 11:14:28 +0100 |
---|---|---|
committer | Dmitry Petrashko <dark@d-d.me> | 2014-12-16 11:14:28 +0100 |
commit | 981a21816e4cb10b8fbe4edcf0659fb3995d63f8 (patch) | |
tree | 88760905657dc850b80b5e97c1c97ce45ab86b23 /src/dotty/tools | |
parent | 78547d17347befa01ffb7379b1e06d1fa07536e2 (diff) | |
parent | a928d99799be8f9ab567b5aca5e21cdd861fb5df (diff) | |
download | dotty-981a21816e4cb10b8fbe4edcf0659fb3995d63f8.tar.gz dotty-981a21816e4cb10b8fbe4edcf0659fb3995d63f8.tar.bz2 dotty-981a21816e4cb10b8fbe4edcf0659fb3995d63f8.zip |
Merge pull request #292 from dotty-staging/fix/#290-type-bind
Fix/#290 type bind
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 9 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala index 002287076..07f8b5525 100644 --- a/src/dotty/tools/dotc/ast/Trees.scala +++ b/src/dotty/tools/dotc/ast/Trees.scala @@ -594,6 +594,8 @@ object Trees { case class Bind[-T >: Untyped] private[ast] (name: Name, body: Tree[T]) extends NameTree[T] with DefTree[T] with PatternTree[T] { type ThisTree[-T >: Untyped] = Bind[T] + override def isType = name.isTypeName + override def isTerm = name.isTermName override def envelope: Position = pos union initialPos } diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 0f1b81be8..17d6478fe 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -357,8 +357,8 @@ trait TypeAssigner { def assignType(tree: untpd.TypeBoundsTree, lo: Tree, hi: Tree)(implicit ctx: Context) = tree.withType(TypeBounds(lo.tpe, hi.tpe)) - def assignType(tree: untpd.Bind, sym: TermSymbol)(implicit ctx: Context) = - tree.withType(TermRef(NoPrefix, sym)) + def assignType(tree: untpd.Bind, sym: Symbol)(implicit ctx: Context) = + tree.withType(NamedType.withFixedSym(NoPrefix, sym)) def assignType(tree: untpd.Alternative, trees: List[Tree])(implicit ctx: Context) = tree.withType(ctx.typeComparer.lub(trees.tpes)) diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 9ba10d000..1fe770462 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -777,7 +777,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) } @@ -799,7 +802,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) } @@ -1340,7 +1343,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) } |