From 87628400a73f9ed033fc2a29e494407234ae6f79 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 16 Dec 2013 21:22:59 +0100 Subject: Eliminating StateFul Was only needed as a parameter to a continuation, so it seemed easier to just pass the components directly. --- src/dotty/tools/dotc/typer/Typer.scala | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index b59832602..f590b7b87 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -46,16 +46,6 @@ object Typer { val nothingBound = 0 def isImportPrec(prec: Int) = prec == namedImport || prec == wildImport } - - /** A result value that is packed with the typer state that was used to - * generate it. - */ - case class StateFul[T](value: T, state: TyperState) { - def commit()(implicit ctx: Context): T = { - state.commit() - value - } - } } class Typer extends Namer with Applications with Implicits { @@ -943,18 +933,18 @@ class Typer extends Namer with Applications with Implicits { def typedPattern(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = typed(tree, pt)(ctx addMode Mode.Pattern) - def tryEither[T](op: Context => T)(fallBack: StateFul[T] => T)(implicit ctx: Context) = { + def tryEither[T](op: Context => T)(fallBack: (T, TyperState) => T)(implicit ctx: Context) = { val nestedCtx = ctx.fresh.withNewTyperState val result = op(nestedCtx) if (nestedCtx.reporter.hasErrors) - fallBack(StateFul(result, nestedCtx.typerState)) + fallBack(result, nestedCtx.typerState) else { nestedCtx.typerState.commit() result } } - def tryInsertApply(tree: Tree, pt: Type)(fallBack: StateFul[Tree] => Tree)(implicit ctx: Context): Tree = + def tryInsertApply(tree: Tree, pt: Type)(fallBack: (Tree, TyperState) => Tree)(implicit ctx: Context): Tree = tryEither { implicit ctx => val sel = typedSelect(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt) @@ -1035,7 +1025,7 @@ class Typer extends Namer with Applications with Implicits { } pt match { case pt: FunProto => - tryInsertApply(tree, pt)(_ => noMatches) + tryInsertApply(tree, pt)((_, _) => noMatches) case _ => if (altDenots exists hasEmptyParams) typed(untpd.Apply(untpd.TypedSplice(tree), Nil), pt) @@ -1057,7 +1047,7 @@ class Typer extends Namer with Applications with Implicits { case Apply(_, _) => " more" case _ => "" } - _ => errorTree(tree, i"$methodStr does not take$more parameters") + (_, _) => errorTree(tree, i"$methodStr does not take$more parameters") } } -- cgit v1.2.3