From 2ede22228c09ca7c2f4ae190ec2086787238ed0a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 16 Dec 2013 19:04:02 +0100 Subject: Small tweaks to typer --- src/dotty/tools/dotc/core/Decorators.scala | 1 + src/dotty/tools/dotc/typer/Typer.scala | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/dotty/tools') diff --git a/src/dotty/tools/dotc/core/Decorators.scala b/src/dotty/tools/dotc/core/Decorators.scala index ca601cddf..cd9680e64 100644 --- a/src/dotty/tools/dotc/core/Decorators.scala +++ b/src/dotty/tools/dotc/core/Decorators.scala @@ -115,6 +115,7 @@ object Decorators { implicit class ListOfListDecorator[T](val xss: List[List[T]]) extends AnyVal { def nestedMap[U](f: T => U): List[List[U]] = xss map (_ map f) + def nestedMapconserve[U](f: T => U): List[List[U]] = xss mapconserve (_ mapconserve f) } implicit class TextToString(val text: Text) extends AnyVal { diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 6b6252638..b59832602 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -394,7 +394,7 @@ class Typer extends Namer with Applications with Implicits { def typedNew(tree: untpd.New, pt: Type)(implicit ctx: Context) = track("typedNew") { tree.tpt match { - case templ: Template => + case templ: untpd.Template => import untpd._ val x = tpnme.ANON_CLASS val clsDef = TypeDef(Modifiers(Final), x, templ) @@ -426,7 +426,7 @@ class Typer extends Namer with Applications with Implicits { cpy.Typed(tree, expr1, tpt1).withType(tpt1.tpe) } tree.expr match { - case id: Ident if (ctx.mode is Mode.Pattern) && isVarPattern(id) => + case id: untpd.Ident if (ctx.mode is Mode.Pattern) && isVarPattern(id) => if (id.name == nme.WILDCARD) regularTyped(isWildcard = true) else { import untpd._ @@ -759,7 +759,7 @@ class Typer extends Namer with Applications with Implicits { val DefDef(mods, name, tparams, vparamss, tpt, rhs) = ddef val mods1 = typedModifiers(mods) val tparams1 = tparams mapconserve (typed(_).asInstanceOf[TypeDef]) - val vparamss1 = vparamss mapconserve(_ mapconserve (typed(_).asInstanceOf[ValDef])) + val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf[ValDef]) val tpt1 = typedType(tpt) val rhs1 = typedExpr(rhs, tpt1.tpe) cpy.DefDef(ddef, mods1, name, tparams1, vparamss1, tpt1, rhs1).withType(sym.termRefWithSig) @@ -930,7 +930,7 @@ class Typer extends Namer with Applications with Implicits { val nestedCtx = if (exprOwner == ctx.owner) ctx else ctx.fresh.withOwner(exprOwner) buf += typed(stat)(nestedCtx) traverse(rest) - case _ => + case nil => buf.toList } traverse(stats) @@ -938,7 +938,7 @@ class Typer extends Namer with Applications with Implicits { def typedExpr(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = typed(tree, pt)(ctx retractMode Mode.PatternOrType) - def typedType(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = + def typedType(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = // todo: retract mode between Type and Pattern? typed(tree, pt)(ctx addMode Mode.Type) def typedPattern(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = typed(tree, pt)(ctx addMode Mode.Pattern) -- cgit v1.2.3