diff options
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/symtab/ClosureHistory.java | 4 | ||||
-rw-r--r-- | sources/scalac/symtab/Type.java | 28 |
2 files changed, 32 insertions, 0 deletions
diff --git a/sources/scalac/symtab/ClosureHistory.java b/sources/scalac/symtab/ClosureHistory.java index 514e093f29..0f5073cd89 100644 --- a/sources/scalac/symtab/ClosureHistory.java +++ b/sources/scalac/symtab/ClosureHistory.java @@ -66,6 +66,10 @@ public class ClosureHistory extends History { for (int i = 0; i < parents.length; i++) addParents(table, parents[i]); return; + case SingleType(_, _): + case ThisType(_): + addParents(table, type.singleDeref()); + return; default: throw Debug.abort("illegal case", type); } diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index f0ebe88b1e..8b7510a597 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -698,6 +698,15 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { } } + /** Is this type a s thistype or singletype? + */ + public boolean isSingletonType() { + switch (this) { + case ThisType(_): case SingleType(_, _): return true; + default: return false; + } + } + /** Is this type a reference to an object type? * todo: replace by this.isSubType(global.definitions.ANY_TYPE())? */ @@ -2155,6 +2164,12 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { && sym == sym1.moduleClass() && sym.owner().thisType().isSameAs(pre1) || + this.singleDeref().isSingletonType() && + this.singleDeref().isSameAs(that) + || + that.singleDeref().isSingletonType() && + this.isSameAs(that.singleDeref()) + || deAlias(that) != that && this.isSameAs(deAlias(that)); } @@ -2165,6 +2180,12 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { case SingleType(Type pre1, Symbol sym1): return sym == sym1 && pre.isSameAs(pre1) || + this.singleDeref().isSingletonType() && + this.singleDeref().isSameAs(that) + || + that.singleDeref().isSingletonType() && + this.isSameAs(that.singleDeref()) + || (deAlias(this) != this || deAlias(that) != that) && deAlias(this).isSameAs(deAlias(that)); case ThisType(Symbol sym1): @@ -2172,6 +2193,12 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { && sym.moduleClass() == sym1 && pre.isSameAs(sym1.owner().thisType()) || + this.singleDeref().isSingletonType() && + this.singleDeref().isSameAs(that) + || + that.singleDeref().isSingletonType() && + this.isSameAs(that.singleDeref()) + || deAlias(this) != this && deAlias(this).isSameAs(that); default: @@ -2280,6 +2307,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { return false; } //where + Type deAlias(Type tp) { switch (tp) { case SingleType(_, _): |