diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-11-03 11:05:48 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-11-07 11:40:03 +1000 |
commit | 51745c06f318f859b313c8257a41221837671ac1 (patch) | |
tree | 3e36f237343fabcd6416701e0f304ae8ed0b4b26 /test/files/pos/t8862b.scala | |
parent | 2d8f919389fa33a554c5fb828bfa040f1b2531e4 (diff) | |
download | scala-51745c06f318f859b313c8257a41221837671ac1.tar.gz scala-51745c06f318f859b313c8257a41221837671ac1.tar.bz2 scala-51745c06f318f859b313c8257a41221837671ac1.zip |
More uniform treatment of package objects
- Introduce `Symbol#packageObject` and `Type#packageObject`
to lookup the member package object of a package class/module,
and use this far and wide.
- Replace the overly complicated (and still buggy) implementation
of `Context#isInPackageObject` with a one liner. The simplifying
insight is that if we select a symbol from a package prefix
that does not own that symbol, it *must* have really been
selected from the package object.
- Change implicit search to use the cache in
`ModuleSymbol#implicitMembers` via `Type#implicitMembers`,
which lets the client code read more naturally.
Fixes a bug with `adapt::insertApply` that Adriaan spotted in a feat
of lateral thinking. This is tested in t8862b.scala. alladin763.scala
adds the test case from the bug originally remedied by `insertApply`
to check we haven't regressed.
Diffstat (limited to 'test/files/pos/t8862b.scala')
-rw-r--r-- | test/files/pos/t8862b.scala | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/files/pos/t8862b.scala b/test/files/pos/t8862b.scala new file mode 100644 index 0000000000..8be7fb5fab --- /dev/null +++ b/test/files/pos/t8862b.scala @@ -0,0 +1,12 @@ +package p { + trait T[X] { def O : { def apply(): X } } + object `package` extends T[Int] { + def O: { def apply(): Int } = new { def apply(): Int = 42 } + } + + object Test { + def main(args: Array[String]): Unit = { + val x: Int = O() + } + } +} |