Permalink
Browse files

SI-8054 Fix regression in TypeRef rebind with val overriding object

Regressed in 8076738 / SI-7928

The condition added in that commit are necessary after refchecks but
poisonous before.

This still seems rather fragile: I wonder if `eliminateModuleDefs`
in `RefChecks` ought to flag the module symbol as `ARTIFACT` after
creating the accessor, so as to signal that it shouldn't be bound
anymore?
  • Loading branch information...
retronym committed Dec 9, 2013
1 parent 7d28c49 commit 369f370b1e894893d315de3bd861c9292695f71d
Showing with 39 additions and 5 deletions.
  1. +8 −5 src/reflect/scala/reflect/internal/Types.scala
  2. +31 −0 test/files/pos/t8054.scala
@@ -3392,11 +3392,14 @@ trait Types
/** Rebind symbol `sym` to an overriding member in type `pre`. */
private def rebind(pre: Type, sym: Symbol): Symbol = {
if (!sym.isOverridableMember || sym.owner == pre.typeSymbol) sym
- else pre.nonPrivateMember(sym.name).suchThat(sym =>
- // SI-7928 `isModuleNotMethod` is here to avoid crashing with overloaded module accessor and module symbols
- // after refchecks eliminates a ModuleDef that implements and interface.
- sym.isType || (!sym.isModuleNotMethod && sym.isStable && !sym.hasVolatileType)
- ) orElse sym
+ else pre.nonPrivateMember(sym.name).suchThat { sym =>
+ // SI-7928 `isModuleNotMethod` is here to avoid crashing with spuriously "overloaded" module accessor and module symbols.
+ // These appear after refchecks eliminates ModuleDefs that implement an interface.
+ // Here, we exclude the module symbol, which allows us to bind to the accessor.
+ // SI-8054 We must only do this after refchecks, otherwise we exclude the module symbol which does not yet have an accessor!
+ val isModuleWithAccessor = phase.refChecked && sym.isModuleNotMethod
+ sym.isType || (!isModuleWithAccessor && sym.isStable && !sym.hasVolatileType)
+ } orElse sym
}
/** Convert a `super` prefix to a this-type if `sym` is abstract or final. */
View
@@ -0,0 +1,31 @@
+trait D {
+ trait Manifest {
+ class Entry
+ }
+
+ val M: Manifest
+
+ def m: M.Entry = ???
+}
+
+object D1 extends D {
+ object M extends Manifest
+}
+
+object D2 extends D {
+ val M: Manifest = ???
+}
+
+object Hello {
+
+ def main(args: Array[String]) {
+ // 2.10.3 - ok
+ // 2.11.0-M7 - type mismatch; found : Seq[DB1.MANIFEST.Entry]
+ // required: Seq[DB1.MANIFEST.Entry]
+ val t1: D1.M.Entry = D1.m
+
+ // 2.10.3 - ok
+ // 2.11.0-M7 - ok
+ val t2: D2.M.Entry = D2.m
+ }
+}

0 comments on commit 369f370

Please sign in to comment.