summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-03-13 16:09:33 -0700
committerPaul Phillips <paulp@improving.org>2013-03-13 16:18:01 -0700
commit4f17806b1d3b0e6fb66a387b74ee9ea15da77ed8 (patch)
tree1b88dcb05917904d3c4d317763660903c64b6432 /src/reflect/scala/reflect/internal/Types.scala
parenta063bb020f2b965b0356491b08c04be0f308872b (diff)
downloadscala-4f17806b1d3b0e6fb66a387b74ee9ea15da77ed8.tar.gz
scala-4f17806b1d3b0e6fb66a387b74ee9ea15da77ed8.tar.bz2
scala-4f17806b1d3b0e6fb66a387b74ee9ea15da77ed8.zip
Eliminated containsNull.
This was a little trickier than the previous. I introduced a new method 'isBottomSubClass' which is the obvious complement to the beloved 'isNonBottomSubClass'. In eliminating the two call sites of containsNull I might have overshot the mark a bit when I rewrote fourthTry and thirdTryRef, but who is going to argue with such beauty as this.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Types.scala')
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 5d2ea1d97f..a678edbe01 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -4051,23 +4051,22 @@ trait Types
corresponds3(tps1, tps2, tparams map (_.variance))(isSubArg)
}
- protected[internal] def containsNull(sym: Symbol): Boolean =
- sym.isClass && sym != NothingClass &&
- !(sym isNonBottomSubClass AnyValClass)
-
- def specializesSym(tp: Type, sym: Symbol, depth: Int): Boolean =
- tp.typeSymbol == NothingClass ||
- tp.typeSymbol == NullClass && containsNull(sym.owner) || {
- def specializedBy(membr: Symbol): Boolean =
- membr == sym || specializesSym(tp.narrow, membr, sym.owner.thisType, sym, depth)
- val member = tp.nonPrivateMember(sym.name)
+ def specializesSym(tp: Type, sym: Symbol, depth: Int): Boolean = {
+ def directlySpecializedBy(member: Symbol): Boolean = (
+ member == sym
+ || specializesSym(tp.narrow, member, sym.owner.thisType, sym, depth)
+ )
+ // Closure reduction, else this would be simply `member exists directlySpecializedBy`
+ def specializedBy(member: Symbol): Boolean = (
if (member eq NoSymbol) false
- else if (member.isOverloaded) member.alternatives exists specializedBy
- else specializedBy(member)
- // was
- // (tp.nonPrivateMember(sym.name).alternatives exists
- // (alt => sym == alt || specializesSym(tp.narrow, alt, sym.owner.thisType, sym, depth)))
- }
+ else if (member.isOverloaded) member.alternatives exists directlySpecializedBy
+ else directlySpecializedBy(member)
+ )
+
+ ( (tp.typeSymbol isBottomSubClass sym.owner)
+ || specializedBy(tp nonPrivateMember sym.name)
+ )
+ }
/** Does member `sym1` of `tp1` have a stronger type
* than member `sym2` of `tp2`?