diff options
4 files changed, 22 insertions, 42 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index f14ec42d74..78169941c8 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -818,13 +818,8 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "") // if tree consists of just x. or x.fo where fo is not yet a full member name // ignore the selection and look in just x. tree match { - case Select(qual, name) if tree.tpe == ErrorType => tree = qual - case ierr: analyzer.InteractiveErrorTree => - ierr.emit(context) - ierr.retrieveEmitted match { - case Select(qual, name) => tree = qual - case _ => - } + case Select(qual, name) if tree.tpe == ErrorType => + tree = qual case _ => } diff --git a/src/compiler/scala/tools/nsc/typechecker/ErrorTrees.scala b/src/compiler/scala/tools/nsc/typechecker/ErrorTrees.scala index a7fecf1373..0b1619e32d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ErrorTrees.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ErrorTrees.scala @@ -19,10 +19,6 @@ trait ErrorTrees { printName(this) } - trait InteractiveErrorTree extends ErrorTree { - def retrieveEmitted: Tree - } - trait ContextError { def errMsg: String def errPos: Position @@ -377,25 +373,6 @@ trait ErrorTrees { def emit(context: Context) { } } - case class NotAMemberInteractive(originalTree: Tree) - extends TreeForwarder(originalTree) with InteractiveErrorTree { - - private[this] var newTree = originalTree - - def emit(context: Context) { - def copyTree = { - val tree1 = originalTree match { - case Select(qual, name) => treeCopy.Select(originalTree, qual, name) - case SelectFromTypeTree(qual, name) => treeCopy.SelectFromTypeTree(originalTree, qual, name) - } - tree1 - } - newTree = copyTree - } - - def retrieveEmitted = newTree - } - case class NotAMemberError(sel: Tree, qual: Tree, name: Name) extends TreeForwarder(sel) with ErrorTree with ContextError { @@ -734,9 +711,12 @@ trait ErrorTrees { case class ErroneousFunInTypeApplyError(fun: Tree, args: List[Tree]) extends TreeForwarder(fun) with ErrorTree { + var errorCache: scala.collection.mutable.ListBuffer[ErrorTree] = null + def emit(context: Context) { - val all = errorTreesFinder(fun) ++ args.map(arg => errorTreesFinder(arg)).flatten - all.foreach(_.emit(context)) + if (errorCache == null) + errorCache = errorTreesFinder(fun) ++ args.map(arg => errorTreesFinder(arg)).flatten + errorCache.foreach(_.emit(context)) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 7ceff8d1d4..0ab619e875 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -606,11 +606,8 @@ trait Implicits { case Apply(TypeApply(fun, args), _) => typedTypeApply(itree2, EXPRmode, fun, args) // t2421c case t => t } - if (checked.containsError()) { - // TODO: for the moment workaround for situations where we get errortrees - val res = errorTreesFinder(checked) - res.foreach(t => t.emit(context)) - } + if (checked.containsError()) + return SearchFailure val result = new SearchResult(checked, subst) incCounter(foundImplicits) printInference("[typedImplicit1] SearchResult: " + result) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 3fff2719b8..710bab8924 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3637,7 +3637,7 @@ trait Typers extends Modes with Adaptations { val appStart = startTimer(failedApplyNanos) val opeqStart = startTimer(failedOpEqNanos) - def onError(reportError: => ErrorTree): Tree = { + def onError(reportError: => Tree): Tree = { fun match { case Select(qual, name) if !isPatternMode && nme.isOpAssignmentName(name.decode) => @@ -3661,7 +3661,7 @@ trait Typers extends Modes with Adaptations { silent(_.typed(fun, forFunMode(mode), funpt), if ((mode & EXPRmode) != 0) false else context.reportAmbiguousErrors, if ((mode & EXPRmode) != 0) tree else context.tree) match { - case fun1: Tree if !fun1.containsError() => + case fun1: Tree if !fun1.containsErrorOrIsErrorTyped() => val fun2 = if (stableApplication) stabilizeFun(fun1, mode, pt) else fun1 incCounter(typedApplyCount) def isImplicitMethod(tpe: Type) = tpe match { @@ -3699,8 +3699,7 @@ trait Typers extends Modes with Adaptations { if (settings.errortrees.value) println("[ErrorTree silent] Encounter error in silent typing of apply") - val ex = quickErrorTreeFinder(eTree) - onError(if (ex.exception == null) ex else TypedApplyError(fun, ex.exception)) + onError(if (eTree.containsError()) {val ex = quickErrorTreeFinder(eTree); if (ex.exception == null) ex else TypedApplyError(fun, ex.exception)} else eTree) case ex: TypeError => onError(TypedApplyError(fun, ex)) @@ -3908,8 +3907,17 @@ trait Typers extends Modes with Adaptations { ) } + def makeInteractiveErrorTree = { + val tree1 = tree match { + case Select(_, _) => treeCopy.Select(tree, qual, name) + case SelectFromTypeTree(_, _) => treeCopy.SelectFromTypeTree(tree, qual, name) + } + setError(tree1) + } + + if (forInteractive) - NotAMemberInteractive(tree) + makeInteractiveErrorTree else if (!qual.tpe.widen.isErroneous) { val lastTry = missingHook(qual.tpe.typeSymbol, name) if (lastTry != NoSymbol) return typed1(tree setSymbol lastTry, mode, pt) |