aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-10 15:19:13 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-10 15:19:13 +0200
commit87ae863c3efa7ce41fed81b783855c572d541898 (patch)
tree590151812be9d41257e7c4b5d5f804853be78d31 /src/dotty/tools/dotc/core/pickling
parent1034d4e420c2b0724945486f341c53a07e6a90e0 (diff)
downloaddotty-87ae863c3efa7ce41fed81b783855c572d541898.tar.gz
dotty-87ae863c3efa7ce41fed81b783855c572d541898.tar.bz2
dotty-87ae863c3efa7ce41fed81b783855c572d541898.zip
Re-organized comparisons of types with classes.
New methods: isClassType, derivesFrom, isArray. Refactored calls to typeSymbol and <:< into these. Made sure to use dealias where needed on remaining typeSymbol calls.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling')
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala4
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index 801841915..4ba4842e1 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -284,7 +284,7 @@ class ClassfileParser(
// NOTE that the comparison to Object only works for abstract types bounded by classes that are strict subclasses of Object
// if the bound is exactly Object, it will have been converted to Any, and the comparison will fail
// see also RestrictJavaArraysMap (when compiling java sources directly)
- if (elemtp.typeSymbol.isAbstractType && !(elemtp <:< defn.ObjectType)) {
+ if (elemtp.typeSymbol.isAbstractType && !(elemtp.derivesFrom(defn.ObjectClass))) {
elemtp = AndType(elemtp, defn.ObjectType)
}
@@ -430,7 +430,7 @@ class ClassfileParser(
def parseAttributes(sym: Symbol, symtype: Type): Type = {
def convertTo(c: Constant, pt: Type): Constant = {
- if (pt.typeSymbol == defn.BooleanClass && c.tag == IntTag)
+ if (pt == defn.BooleanType && c.tag == IntTag)
Constant(c.value != 0)
else
c convertTo pt
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 1d748ae55..3168bb37c 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -82,10 +82,10 @@ object UnPickler {
def arrayToRepeated(tp: Type)(implicit ctx: Context): Type = tp match {
case tp @ MethodType(paramNames, paramTypes) =>
val lastArg = paramTypes.last
- assert(lastArg.typeSymbol == defn.ArrayClass)
+ assert(lastArg.isArray)
val elemtp0 :: Nil = lastArg.typeArgs
val elemtp = elemtp0 match {
- case AndType(t1, t2) if t1.typeSymbol.isAbstractType && t2.typeSymbol == defn.ObjectClass =>
+ case AndType(t1, t2) if t1.typeSymbol.isAbstractType && t2.isClassType(defn.ObjectClass) =>
t1 // drop intersection with Object for abstract types in varargs. UnCurry can handle them.
case _ =>
elemtp0
@@ -550,7 +550,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
*/
def elimExistentials(boundSyms: List[Symbol], tp: Type): Type = {
def removeSingleton(tp: Type): Type =
- if (tp.typeSymbol == defn.SingletonClass) defn.AnyType else tp
+ if (tp.isClassType(defn.SingletonClass)) defn.AnyType else tp
def elim(tp: Type): Type = tp match {
case tp @ RefinedType(parent, name) =>
val parent1 = elim(tp.parent)
@@ -559,7 +559,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
RefinedType(parent1, name, info.fixedSym.info)
case info: TypeRefBySym if boundSyms contains info.fixedSym =>
val info1 = info.fixedSym.info
- assert(info1 <:< defn.SingletonClass.typeConstructor)
+ assert(info1.derivesFrom(defn.SingletonClass))
RefinedType(parent1, name, info1.mapAnd(removeSingleton))
case info =>
tp.derivedRefinedType(parent1, name, info)