Permalink
Browse files

Centrally unify module class representations.

There are these two representations of a type we wish to
treat as the same:

  TypeRef(pre, sym1, Nil) // sym1.isModuleClass, sym1.sourceModule == sym2
  SingleType(pre, sym2)   // sym2.isModule, sym2.moduleClass == sym1

I rolled the recognition of this into normalizePlus where it
won't bother anyone. normalizePlus is the last effort undertaken
by isSameType before it gives up. This allowed significant
simplification of logic elsewhere, since there is a great
deal of logic working around the fact that a TypeRef might
be equivalent to a SingleType even after dealiasing.
  • Loading branch information...
1 parent ca2a09d commit 6bde11e531b32cc12b1185c5fe6a9135ab2a9b6b @paulp paulp committed Apr 4, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/reflect/scala/reflect/internal/Types.scala
@@ -3884,9 +3884,14 @@ trait Types
}
}
- def normalizePlus(tp: Type) =
+ def normalizePlus(tp: Type) = (
if (isRawType(tp)) rawToExistential(tp)
- else tp.normalize
+ else tp.normalize match {
+ // Unify the two representations of module classes
+ case st @ SingleType(_, sym) if sym.isModule => st.underlying.normalize
+ case _ => tp.normalize
+ }
+ )
/*
todo: change to:

0 comments on commit 6bde11e

Please sign in to comment.