From 099f42f725cf516b2bc4586e87ec11475c5f2698 Mon Sep 17 00:00:00 2001 From: Miles Sabin Date: Sat, 20 Feb 2010 20:32:40 +0000 Subject: Another attempt at retaining ill-typed trees fo... Another attempt at retaining ill-typed trees for the IDE, this time without breaking scaladoc. Review by extempore. --- .../scala/tools/nsc/interactive/Global.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 32 ++++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 99117e014b..d8ea6df97d 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -494,7 +494,7 @@ self => println("starting typedTreeAt") val tree = locateTree(pos) println("at pos "+pos+" was found: "+tree+tree.pos.show) - if (tree.tpe ne null) { + if (stabilizedType(tree) ne null) { println("already attributed") tree } else { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index e39f552458..9325fa1e2b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -711,14 +711,19 @@ trait Typers { self: Analyzer => else qual.tpe.nonLocalMember(name) } - def silent[T](op: Typer => T): Any /* in fact, TypeError or T */ = { + def silent[T](op: Typer => T) : Any = silent(false, op) + def noisy[T](op: Typer => T) = silent(true, op) + + def silent[T](report : Boolean, op: Typer => T): Any /* in fact, TypeError or T */ = { val rawTypeStart = startCounter(rawTypeFailed) val findMemberStart = startCounter(findMemberFailed) val subtypeStart = startCounter(subtypeFailed) val failedSilentStart = startTimer(failedSilentNanos) try { - if (context.reportGeneralErrors) { - val context1 = context.makeSilent(context.reportAmbiguousErrors) + if (context.reportGeneralErrors != report) { + val context1 = context.make(context.tree) + context1.reportGeneralErrors = report + context1.reportAmbiguousErrors = context.reportAmbiguousErrors context1.undetparams = context.undetparams context1.savedTypeBounds = context.savedTypeBounds context1.namedApplyBlockInfo = context.namedApplyBlockInfo @@ -3303,12 +3308,21 @@ trait Typers { self: Analyzer => if (printTypings) println("second try for: "+fun+" and "+args) val Select(qual, name) = fun val args1 = tryTypedArgs(args, argMode(fun, mode), ex) - val qual1 = - if ((args1 ne null) && !pt.isError) adaptToArguments(qual, name, args1, pt) - else qual - if (qual1 ne qual) { - val tree1 = Apply(Select(qual1, name) setPos fun.pos, args1) setPos tree.pos - return typed1(tree1, mode | SNDTRYmode, pt) + if ((args1 eq null) && onlyPresentation) { + return noisy(_.doTypedApply(tree, fun, args, mode, pt)) match { + case t: Tree => t + case ex: TypeError => + reportTypeError(tree.pos, ex) + setError(tree) + } + } else { + val qual1 = + if ((args1 ne null) && !pt.isError) adaptToArguments(qual, name, args1, pt) + else qual + if (qual1 ne qual) { + val tree1 = Apply(Select(qual1, name) setPos fun.pos, args1) setPos tree.pos + return typed1(tree1, mode | SNDTRYmode, pt) + } } } else if (printTypings) { println("no second try for "+fun+" and "+args+" because error not in result:"+ex.pos+"!="+tree.pos) -- cgit v1.2.3