aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala20
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala20
2 files changed, 17 insertions, 23 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 5912e5e7b..857ff31ff 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -458,7 +458,7 @@ trait Applications extends Compatibility { self: Typer =>
else new ApplyToUntyped(tree, fun1, funRef, proto, pt)
val result = app.result
ConstFold(result) orElse result
- } { failed => fun1 match {
+ } { (failedVal, failedState) => fun1 match {
case Select(qual, name) =>
// try with prototype `[].name(args)`, this might succeed by inserting an
// implicit conversion around []. (an example is Int + BigInt).
@@ -471,10 +471,13 @@ trait Applications extends Compatibility { self: Typer =>
cpy.Select(fun1, untpd.TypedSplice(qual1), name),
proto.typedArgs map untpd.TypedSplice),
pt)
- } { _ => failed.commit()
+ } { (_, _) =>
+ failedState.commit()
+ failedVal
}
case _ =>
- failed.commit()
+ failedState.commit()
+ failedVal
}
}
case _ =>
@@ -505,11 +508,12 @@ trait Applications extends Compatibility { self: Typer =>
if (untpd.isOpAssign(tree))
tryEither {
implicit ctx => realApply
- } { failed =>
+ } { (failedVal, failedState) =>
tryEither {
implicit ctx => typedOpAssign
- } { _ =>
- failed.commit()
+ } { (_, _) =>
+ failedState.commit()
+ failedVal
}
}
else realApply
@@ -546,11 +550,11 @@ trait Applications extends Compatibility { self: Typer =>
tryEither {
implicit ctx => typedExpr(untpd.Select(qual, nme.unapply), unappProto)
} {
- s =>
+ (sel, _) =>
tryEither {
implicit ctx => typedExpr(untpd.Select(qual, nme.unapplySeq), unappProto) // for backwards compatibility; will be dropped
} {
- _ => notAnExtractor(s.value)
+ (_, _) => notAnExtractor(sel)
}
}
}
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")
}
}