diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-05-21 00:04:52 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-05-21 00:04:52 +0200 |
commit | 03e6d929ee639de292daa778dde514e1b7014eac (patch) | |
tree | 0023a804cfc04aa5c429cb26e55b28e933118c19 | |
parent | 1f5584fbe183041d4af269278f0125e2f0b94a44 (diff) | |
download | scala-03e6d929ee639de292daa778dde514e1b7014eac.tar.gz scala-03e6d929ee639de292daa778dde514e1b7014eac.tar.bz2 scala-03e6d929ee639de292daa778dde514e1b7014eac.zip |
Consider method-scoped companions in the implicit scope.
Fixes SI-4975.
I'll reproduce a relevant snippet of dialogue from Namers#companionSymbolOf:
/** The companion class or companion module of `original`.
* Calling .companionModule does not work for classes defined inside methods.
*
* !!! Then why don't we fix companionModule? Does the presence of these
* methods imply all the places in the compiler calling sym.companionModule are
* bugs waiting to be reported? If not, why not? When exactly do we need to
* call this method?
*/
def companionSymbolOf(original: Symbol, ctx: Context): Symbol = {
This was one such bug.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t4975.scala | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 8f025336bb..9d33f3d828 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -929,7 +929,7 @@ trait Implicits { } case None => if (pre.isStable) { - val companion = sym.companionModule + val companion = companionSymbolOf(sym, context) companion.moduleClass match { case mc: ModuleClassSymbol => val infos = diff --git a/test/files/pos/t4975.scala b/test/files/pos/t4975.scala new file mode 100644 index 0000000000..12d889c0d5 --- /dev/null +++ b/test/files/pos/t4975.scala @@ -0,0 +1,12 @@ +object ImplicitScope { + class A[T] + + def foo { + trait B + object B { + implicit def ab = new A[B] + } + + implicitly[A[B]] // Error + } +} |