diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-19 11:25:19 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-19 13:18:14 -0800 |
commit | 8deade7d868dbd79194621d815ee6eee46f9807d (patch) | |
tree | af00ccb2273b8192e6155d8f27c70c5b868b28d0 /src/compiler | |
parent | a1b70c17d2c92e66de685985a435a895a79d7b4c (diff) | |
download | scala-8deade7d868dbd79194621d815ee6eee46f9807d.tar.gz scala-8deade7d868dbd79194621d815ee6eee46f9807d.tar.bz2 scala-8deade7d868dbd79194621d815ee6eee46f9807d.zip |
Avoid calculating similar strings sometimes.
Like when they're useless. As per suggestion from moors.
Closes SI-5382.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 21 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index f199195b81..faff4ccab2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -122,6 +122,10 @@ trait Contexts { self: Analyzer => var typingIndentLevel: Int = 0 def typingIndent = " " * typingIndentLevel + def enclClassOrMethod: Context = + if ((owner eq NoSymbol) || (owner.isClass) || (owner.isMethod)) this + else outer.enclClassOrMethod + def undetparamsString = if (undetparams.isEmpty) "" else undetparams.mkString("undetparams=", ", ", "") diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 884ad7af3d..b4221365be 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3800,6 +3800,9 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { var cx = startingIdentContext while (defSym == NoSymbol && cx != NoContext) { + // !!! Shouldn't the argument to compileSourceFor be cx, not context? + // I can't tell because those methods do nothing in the standard compiler, + // presumably they are overridden in the IDE. currentRun.compileSourceFor(context.asInstanceOf[analyzer.Context], name) pre = cx.enclClass.prefix defEntry = cx.scope.lookupEntry(name) @@ -3914,9 +3917,18 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { // Avoiding some spurious error messages: see SI-2388. if (reporter.hasErrors && (name startsWith tpnme.ANON_CLASS_NAME)) () else { - val similar = ( - // name length check to limit unhelpful suggestions for e.g. "x" and "b1" - if (name.length > 2) { + // This laborious determination arrived at to keep the tests working. + val calcSimilar = ( + name.length > 2 && ( + startingIdentContext.reportGeneralErrors + || startingIdentContext.enclClassOrMethod.reportGeneralErrors + ) + ) + // avoid calculating if we're in "silent" mode. + // name length check to limit unhelpful suggestions for e.g. "x" and "b1" + val similar = { + if (!calcSimilar) "" + else { val allowed = ( startingIdentContext.enclosingContextChain flatMap (ctx => ctx.scope.toList ++ ctx.imports.flatMap(_.allImportedSymbols)) @@ -3929,8 +3941,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { ) similarString("" + name, allowedStrings) } - else "" - ) + } error(tree.pos, "not found: "+decodeWithKind(name, context.owner) + similar) } } |