diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-10-23 11:29:09 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-10-23 11:47:49 +0200 |
commit | 80767383fdc52a444295fdc2ab5f4b9fbfa1c352 (patch) | |
tree | a64ac9971ba5ab6e12f44f819420e2572da12fdd /test/osgi | |
parent | 0c2d73755b3db80d976231b44b66107db5412426 (diff) | |
download | scala-80767383fdc52a444295fdc2ab5f4b9fbfa1c352.tar.gz scala-80767383fdc52a444295fdc2ab5f4b9fbfa1c352.tar.bz2 scala-80767383fdc52a444295fdc2ab5f4b9fbfa1c352.zip |
SI-7928 Favour module accessors symbols in rebind
The Refchecks tree transformer transforms a nested modules that
overrides a method into a pair of symbols: the module itself, and
an module accessor that matches the overridden symbol.
[[syntax trees at end of typer]] // test1.scala
package <empty> {
abstract trait C2 extends scala.AnyRef {
def O1: Any
};
class C1 extends AnyRef with C2 {
object O1 extends scala.AnyRef
}
}
[[syntax trees at end of refchecks]] // test1.scala
package <empty> {
abstract trait C2 extends scala.AnyRef {
def O1: Any
};
class C1 extends AnyRef with C2 {
object O1 extends scala.AnyRef
@volatile <synthetic> private[this] var O1$module: C1.this.O1.type = _;
<stable> def O1: C1.this.O1.type = {
C1.this.O1$module = new C1.this.O1.type();
C1.this.O1$module
}
}
}
When constructing a TypeRef or SingleType with a prefix and and a symbol,
the factory methods internally use `rebind` to see if the provided symbol
should be replaced with an overriding symbol that is available in that prefix.
Trying this out in the REPL is a bit misleading, because even if you change
phase to `refchecks`, you won't get the desired results because the transform
is not done in an InfoTransformer.
scala> val O1 = typeOf[C1].decl(TermName("O1"))
O1: $r.intp.global.Symbol = object O1
scala> typeRef(typeOf[C2], O1, Nil)
res13: $r.intp.global.Type = C2#O1
scala> res13.asInstanceOf[TypeRef].sym.owner
res14: $r.intp.global.Symbol = class C1
But debugging the test case, we get into `rebind` during an AsSeenFrom
which is where we crashed when `suchThat` encountered the overloaded
module and module accessor symbols:
typeOf[OuterObject.Inner.type].memberType(symbolOf[InnerTrait.Collection])
...
singleTypeAsSeen(OuterTrait.this.Inner.type)
val SingleType(pre, sym) = tp
// pre = OuterTrait.this.type
// sym = OuterTrait.Inner
val pre1 = this(pre) // OuterObject.type
singleType(pre1, sym)
rebind(pre1, sym) // was crashing, now OuterObject.Inner
}
This commit excludes the module symbol from symbol lookup in the prefix in rebind.
Diffstat (limited to 'test/osgi')
0 files changed, 0 insertions, 0 deletions