From ff9cfd9eb7f47be69d302f73de08a00303249a0d Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 3 Dec 2012 18:34:18 +0100 Subject: Don't return unimportables from importedSymbol. Hardening against the symptom of SI-6745, which yielded: wat.scala:4: error: too many arguments for constructor Predef: ()object Predef def this() = this(0) ^ The fix for the underlying problem in that bug has been targetted at branch 2.10.x. --- .../scala/tools/nsc/typechecker/Contexts.scala | 9 ++++++++- test/files/run/t6745-2.scala | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t6745-2.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 1af61d31ec..c0d2f44c7b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -996,7 +996,14 @@ trait Contexts { self: Analyzer => if (settings.lint.value && selectors.nonEmpty && result != NoSymbol && pos != NoPosition) recordUsage(current, result) - result + // Harden against the fallout from bugs like SI-6745 + // + // [JZ] I considered issuing a devWarning and moving the + // check inside the above loop, as I believe that + // this always represents a mistake on the part of + // the caller. + if (definitions isImportable result) result + else NoSymbol } private def selectorString(s: ImportSelector): String = { if (s.name == nme.WILDCARD && s.rename == null) "_" diff --git a/test/files/run/t6745-2.scala b/test/files/run/t6745-2.scala new file mode 100644 index 0000000000..31ecd42bd1 --- /dev/null +++ b/test/files/run/t6745-2.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc._ +import scala.tools.partest.CompilerTest +import scala.collection.{ mutable, immutable, generic } + +object Test extends CompilerTest { + import global._ + import rootMirror._ + import definitions._ + import global.analyzer.{Context, ImportInfo} + + override def code = """ +package context { +} + """ + + def check(source: String, unit: global.CompilationUnit) = { + val context: Context = global.analyzer.rootContext(unit) + val importInfo: ImportInfo = context.imports.head // Predef._ + val importedSym = importInfo.importedSymbol(nme.CONSTRUCTOR) + assert(importedSym == NoSymbol, importedSym) // was "constructor Predef" + } +} -- cgit v1.2.3