diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2017-01-20 07:45:14 +1100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2017-01-20 08:28:45 +1100 |
commit | 1d41aef53506a4e697f848e790e03f204d05885d (patch) | |
tree | f08aff51af34f9bd7e55fd56013912cf8221f229 /src/compiler | |
parent | 82b2470ff681a4dfe4aed5c2ce6c27bd1ad0c71a (diff) | |
download | scala-1d41aef53506a4e697f848e790e03f204d05885d.tar.gz scala-1d41aef53506a4e697f848e790e03f204d05885d.tar.bz2 scala-1d41aef53506a4e697f848e790e03f204d05885d.zip |
SI-10154 Fix implicit search regression for term-owned objects
A recent change to fix lookup of companion implicits of term-owned
classes (#5550) caused a regression in the enclosed test case. The
previous approach of calling `Scope#lookup(companionName)` was
replaced by a lookup of the scope entry of the original name followed
by a narrower search lookup for the companion name, to ensure
that it was a true companion, and not just a same-named module
from defined at a different nested scope.
However, module class symbols are not themselves entered into
scopes, so the first part of the new scheme fails. We need to
add a special case modules here.
I've chosen to just call `.sourceModule` on module classes.
For module classes in the current run (all term owned symbols
will fall into this category), this amounts to using the value
of the field `ModuleClassSymbol#module`.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index fde2f7bb03..d349597b14 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -1194,7 +1194,8 @@ trait Contexts { self: Analyzer => } final def lookupCompanionOf(original: Symbol): Symbol = { - lookupScopeEntry(original) match { + if (original.isModuleClass) original.sourceModule + else lookupScopeEntry(original) match { case null => NoSymbol case entry => entry.owner.lookupCompanion(original) } |