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 /test/files/pos | |
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 'test/files/pos')
-rw-r--r-- | test/files/pos/t10154.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t10154b.scala | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/test/files/pos/t10154.scala b/test/files/pos/t10154.scala new file mode 100644 index 0000000000..51616b71d6 --- /dev/null +++ b/test/files/pos/t10154.scala @@ -0,0 +1,11 @@ +trait Bar2[T] + +object Test2 { + def wrap { + object Foo { + implicit def fooBar: Bar2[Foo.type] = ??? + } + + implicitly[Bar2[Foo.type]] + } +} diff --git a/test/files/pos/t10154b.scala b/test/files/pos/t10154b.scala new file mode 100644 index 0000000000..809a286c0e --- /dev/null +++ b/test/files/pos/t10154b.scala @@ -0,0 +1,16 @@ + import scala.language.existentials + + class Bar[T] + class Test { + def method = { + object Foo { + implicit def x: Bar[Foo.type] = new Bar[Foo.type] + } + type T = Foo.type + + { + object Foo + implicitly[Bar[T]] + } + } +} |