diff options
author | Martin Odersky <odersky@gmail.com> | 2013-03-04 11:53:46 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-03-04 11:53:46 +0100 |
commit | 5af6ff8286614998e58f0bc5ef2fe4135d993209 (patch) | |
tree | 05ad16fb264d918b23210ca9b34d8ee2a875c5bf /src/dotty/tools/dotc | |
parent | a462570e3a7c5188ae5e6e4e76a16522bee10f1c (diff) | |
download | dotty-5af6ff8286614998e58f0bc5ef2fe4135d993209.tar.gz dotty-5af6ff8286614998e58f0bc5ef2fe4135d993209.tar.bz2 dotty-5af6ff8286614998e58f0bc5ef2fe4135d993209.zip |
Renamed RefinedType#name, #info…
… to refinedName, refinedInfo. Also some other polishings in Types.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/Printers.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Substituters.scala | 14 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparers.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 80 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 2 |
7 files changed, 49 insertions, 67 deletions
diff --git a/src/dotty/tools/dotc/core/Printers.scala b/src/dotty/tools/dotc/core/Printers.scala index 4c97a5bfa..56f32f50d 100644 --- a/src/dotty/tools/dotc/core/Printers.scala +++ b/src/dotty/tools/dotc/core/Printers.scala @@ -127,11 +127,11 @@ object Printers { /** String representation of a name used in a refinement * In refined printing this undoes type parameter expansion */ - protected def showRefinementName(tp: RefinedType) = show(tp.name) + protected def showRefinementName(tp: RefinedType) = show(tp.refinedName) /** String representation of a refinement */ protected def showRefinement(rt: RefinedType) = - showRefinementName(rt) + showRHS(rt.info) + showRefinementName(rt) + showRHS(rt.refinedInfo) /** The longest sequence refinement types, starting at given type * and following parents. @@ -397,7 +397,7 @@ object Printers { } override protected def showRefinementName(tp: RefinedType): String = { - val tsym = tp.member(tp.name).symbol + val tsym = tp.member(tp.refinedName).symbol val name = tsym.originalName show(if (tsym is ExpandedTypeParam) name.asTypeName.unexpandedName() else name) } diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala index d4ead33b1..5d0dd6add 100644 --- a/src/dotty/tools/dotc/core/Substituters.scala +++ b/src/dotty/tools/dotc/core/Substituters.scala @@ -17,7 +17,7 @@ trait Substituters { this: Context => case _: ThisType | NoPrefix => tp case tp: RefinedType => - tp.derivedRefinedType(subst(tp.parent, from, to, map), tp.name, subst(tp.info, from, to, map)) + tp.derivedRefinedType(subst(tp.parent, from, to, map), tp.refinedName, subst(tp.refinedInfo, from, to, map)) case _ => (if (map != null) map else new SubstBindingMap(from, to)) .mapOver(tp) @@ -33,7 +33,7 @@ trait Substituters { this: Context => case _: ThisType | _: BoundType | NoPrefix => tp case tp: RefinedType => - tp.derivedRefinedType(subst1(tp.parent, from, to, map), tp.name, subst1(tp.info, from, to, map)) + tp.derivedRefinedType(subst1(tp.parent, from, to, map), tp.refinedName, subst1(tp.refinedInfo, from, to, map)) case _ => (if (map != null) map else new Subst1Map(from, to)) .mapOver(tp) @@ -51,7 +51,7 @@ trait Substituters { this: Context => case _: ThisType | _: BoundType | NoPrefix => tp case tp: RefinedType => - tp.derivedRefinedType(subst2(tp.parent, from1, to1, from2, to2, map), tp.name, subst2(tp.info, from1, to1, from2, to2, map)) + tp.derivedRefinedType(subst2(tp.parent, from1, to1, from2, to2, map), tp.refinedName, subst2(tp.refinedInfo, from1, to1, from2, to2, map)) case _ => (if (map != null) map else new Subst2Map(from1, to1, from2, to2)) .mapOver(tp) @@ -74,7 +74,7 @@ trait Substituters { this: Context => case _: ThisType | _: BoundType | NoPrefix => tp case tp: RefinedType => - tp.derivedRefinedType(subst(tp.parent, from, to, map), tp.name, subst(tp.info, from, to, map)) + tp.derivedRefinedType(subst(tp.parent, from, to, map), tp.refinedName, subst(tp.refinedInfo, from, to, map)) case _ => (if (map != null) map else new SubstMap(from, to)) .mapOver(tp) @@ -97,7 +97,7 @@ trait Substituters { this: Context => case _: ThisType | _: BoundType | NoPrefix => tp case tp: RefinedType => - tp.derivedRefinedType(substSym(tp.parent, from, to, map), tp.name, substSym(tp.info, from, to, map)) + tp.derivedRefinedType(substSym(tp.parent, from, to, map), tp.refinedName, substSym(tp.refinedInfo, from, to, map)) case _ => (if (map != null) map else new SubstSymMap(from, to)) .mapOver(tp) @@ -113,7 +113,7 @@ trait Substituters { this: Context => case _: BoundType | NoPrefix => tp case tp: RefinedType => - tp.derivedRefinedType(substThis(tp.parent, from, to, map), tp.name, substThis(tp.info, from, to, map)) + tp.derivedRefinedType(substThis(tp.parent, from, to, map), tp.refinedName, substThis(tp.refinedInfo, from, to, map)) case _ => (if (map != null) map else new SubstThisMap(from, to)) .mapOver(tp) @@ -129,7 +129,7 @@ trait Substituters { this: Context => case _: ThisType | _: BoundType | NoPrefix => tp case tp: RefinedType => - tp.derivedRefinedType(substThis(tp.parent, from, to, map), tp.name, substThis(tp.info, from, to, map)) + tp.derivedRefinedType(substThis(tp.parent, from, to, map), tp.refinedName, substThis(tp.refinedInfo, from, to, map)) case _ => (if (map != null) map else new SubstRefinedThisMap(from, to)) .mapOver(tp) diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 0fb099bdb..260cf8bb2 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -826,7 +826,7 @@ object SymDenotations { def memberNames(keepOnly: NameFilter)(implicit ctx: Context): Set[Name] = { def computeMemberNames: Set[Name] = { - val inheritedNames = (classInfo.classParents flatMap (_.memberNames(thisType, keepOnly))).toSet + val inheritedNames = (classInfo.classParents flatMap (_.memberNames(keepOnly, thisType))).toSet val ownNames = info.decls.iterator map (_.name) val candidates = inheritedNames ++ ownNames candidates filter (keepOnly(thisType, _)) diff --git a/src/dotty/tools/dotc/core/TypeComparers.scala b/src/dotty/tools/dotc/core/TypeComparers.scala index c9c2f17b6..2bdad0d50 100644 --- a/src/dotty/tools/dotc/core/TypeComparers.scala +++ b/src/dotty/tools/dotc/core/TypeComparers.scala @@ -118,7 +118,7 @@ object TypeComparers { thirdTryRef(tp1, tp2) case tp2: RefinedType => isSubType(tp1, tp2.parent) && - isSubType(tp1.member(tp2.name).info, tp2.info) + isSubType(tp1.member(tp2.refinedName).info, tp2.refinedInfo) case AndType(tp21, tp22) => isSubType(tp1, tp21) && isSubType(tp1, tp22) case OrType(tp21, tp22) => diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 6628aa824..ddab2743d 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -50,8 +50,8 @@ trait TypeOps { this: Context => case tp: RefinedType => tp.derivedRefinedType( asSeenFrom(tp.parent, pre, clazz, theMap), - tp.name, - asSeenFrom(tp.info, pre, clazz, theMap)) + tp.refinedName, + asSeenFrom(tp.refinedInfo, pre, clazz, theMap)) case _ => (if (theMap != null) theMap else new AsSeenFromMap(pre, clazz)) .mapOver(tp) @@ -76,7 +76,7 @@ trait TypeOps { this: Context => case tp: RefinedType => tp.parent.isVolatile || isAbstractIntersection(tp.parent) && - (tp.abstractMemberNames contains tp.name) + (tp.abstractMemberNames() contains tp.refinedName) case tp: TypeProxy => tp.underlying.isVolatile case AndType(l, r) => @@ -204,8 +204,8 @@ trait TypeOps { this: Context => case tp @ RefinedType(tp1, name: TypeName) => refinements = refinements.updated(name, refinements get name match { - case Some(info) => info & tp.info - case none => tp.info + case Some(info) => info & tp.refinedInfo + case none => tp.refinedInfo }) formals = formals.updated(name, tp1.member(name).symbol) normalizeToRef(tp1) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index e1076bdc8..546b8c676 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -88,59 +88,41 @@ object Types { * T is stable or T contains no uninstantiated type variables. */ final def isLegalPrefix(implicit ctx: Context): Boolean = - isStable || abstractTypeNames(this).isEmpty - - /** The set of names that denote an abstract type member of this type - * which is also an abstract type member of `pre` - */ - final def abstractTypeNames(pre: Type)(implicit ctx: Context): Set[Name] = - memberNames(pre, abstractTypeNameFilter) - final def abstractTypeNames(implicit ctx: Context): Set[Name] = - abstractTypeNames(this) - - /** The set of names that denote an abstract term member of this type - * which is also an abstract term member of `pre` - */ - final def abstractTermNames(pre: Type)(implicit ctx: Context): Set[Name] = - memberNames(pre, abstractTermNameFilter) - final def abstractTermNames(implicit ctx: Context): Set[Name] = - abstractTermNames(this) - - /** The set of names that denote an abstract member of this type - * which is also an abstract member of `pre` - */ - final def abstractMemberNames(pre: Type)(implicit ctx: Context): Set[Name] = - abstractTypeNames(pre) | abstractTermNames(pre) - final def abstractMemberNames(implicit ctx: Context): Set[Name] = - abstractMemberNames(this) - - final def abstractTermMembers(pre: Type)(implicit ctx: Context): Set[SingleDenotation] = - abstractTermNames.flatMap(name => - pre.member(name).altsWith(_ is Deferred)) - final def abstractTermMembers(implicit ctx: Context): Set[SingleDenotation] = - abstractTermMembers(this) + isStable || memberNames(abstractTypeNameFilter).isEmpty /** The set of names of members of this type that pass the given name filter * when seen as members of `pre`. More precisely, these are all * of members `name` such that `keepOnly(pre, name)` is `true`. */ - final def memberNames(pre: Type, keepOnly: NameFilter)(implicit ctx: Context): Set[Name] = this match { + final def memberNames(keepOnly: NameFilter, pre: Type = this)(implicit ctx: Context): Set[Name] = this match { case tp: ClassInfo => tp.cls.memberNames(keepOnly) filter (keepOnly(pre, _)) case tp: RefinedType => - var ns = tp.parent.memberNames(pre, keepOnly) - if (keepOnly(pre, tp.name)) ns += tp.name + var ns = tp.parent.memberNames(keepOnly, pre) + if (keepOnly(pre, tp.refinedName)) ns += tp.refinedName ns case tp: AndType => - tp.tp1.memberNames(pre, keepOnly) | tp.tp2.memberNames(pre, keepOnly) + tp.tp1.memberNames(keepOnly, pre) | tp.tp2.memberNames(keepOnly, pre) case tp: OrType => - tp.tp1.memberNames(pre, keepOnly) & tp.tp2.memberNames(pre, keepOnly) + tp.tp1.memberNames(keepOnly, pre) & tp.tp2.memberNames(keepOnly, pre) case tp: TypeProxy => - tp.underlying.memberNames(pre, keepOnly) + tp.underlying.memberNames(keepOnly, pre) case _ => Set() } + /** The set of names that denote an abstract member of this type + * which is also an abstract member of `pre`. + */ + final def abstractMemberNames(pre: Type = this)(implicit ctx: Context): Set[Name] = + memberNames(abstractTypeNameFilter, pre) | + memberNames(abstractTermNameFilter, pre) + + /** The set of abstract term members of this type. */ + final def abstractTermMembers(implicit ctx: Context): Set[SingleDenotation] = + memberNames(abstractTermNameFilter) + .flatMap(member(_).altsWith(_ is Deferred)) + /** Is this type a value type */ final def isValueType: Boolean = this match { case NoPrefix @@ -374,8 +356,8 @@ object Types { final def findMember(name: Name, pre: Type, excluded: FlagSet)(implicit ctx: Context): Denotation = this match { case tp: RefinedType => val pdenot = tp.parent.findMember(name, pre, excluded) - if (name eq tp.name) - pdenot & new JointRefDenotation(NoSymbol, tp.info.substThis(tp, pre), Period.allInRun(ctx.runId)) + if (name eq tp.refinedName) + pdenot & new JointRefDenotation(NoSymbol, tp.refinedInfo.substThis(tp, pre), Period.allInRun(ctx.runId)) else pdenot case tp: TypeProxy => @@ -533,7 +515,7 @@ object Types { if (tycon != NoType) { val tparam = tycon.typeParams.apply(nparams) if (tparam.name == name) { - (tycon, args :+ tp.info.argType(tparam)) + (tycon, args :+ tp.refinedInfo.argType(tparam)) } else fail } else fail } else fail @@ -896,20 +878,20 @@ object Types { // --- Refined Type --------------------------------------------------------- - abstract case class RefinedType(parent: Type, name: Name)(infof: RefinedType => Type) extends CachedProxyType with BindingType { + abstract case class RefinedType(parent: Type, refinedName: Name)(infof: RefinedType => Type) extends CachedProxyType with BindingType { - val info: Type = infof(this) + val refinedInfo: Type = infof(this) override def underlying(implicit ctx: Context) = parent - def derivedRefinedType(parent: Type, name: Name, info: Type)(implicit ctx: Context): RefinedType = - if ((parent eq this.parent) && (name eq this.name) && (info eq this.info)) this - else RefinedType(parent, name, rt => info.substThis(this, RefinedThis(rt))) + def derivedRefinedType(parent: Type, refinedName: Name, refinedInfo: Type)(implicit ctx: Context): RefinedType = + if ((parent eq this.parent) && (refinedName eq this.refinedName) && (refinedInfo eq this.refinedInfo)) this + else RefinedType(parent, refinedName, rt => refinedInfo.substThis(this, RefinedThis(rt))) - override def computeHash = doHash(name, info, parent) + override def computeHash = doHash(refinedName, refinedInfo, parent) } - class CachedRefinedType(parent: Type, name: Name, infof: RefinedType => Type) extends RefinedType(parent, name)(infof) + class CachedRefinedType(parent: Type, refinedName: Name, infof: RefinedType => Type) extends RefinedType(parent, refinedName)(infof) object RefinedType { def make(parent: Type, names: List[Name], infofs: List[RefinedType => Type])(implicit ctx: Context): Type = @@ -1275,7 +1257,7 @@ object Types { | _: BoundType => tp case tp: RefinedType => - tp.derivedRefinedType(this(tp.parent), tp.name, this(tp.info)) + tp.derivedRefinedType(this(tp.parent), tp.refinedName, this(tp.refinedInfo)) case tp @ PolyType(pnames) => tp.derivedPolyType( @@ -1362,7 +1344,7 @@ object Types { | _: BoundType => x case tp: RefinedType => - this(this(x, tp.parent), tp.info) + this(this(x, tp.parent), tp.refinedInfo) case tp @ PolyType(pnames) => this((x /: tp.paramBounds)(this), tp.resultType) diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index 55ed9b63d..dfb6be7d6 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -438,7 +438,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleRoot: Clas def elim(tp: Type): Type = tp match { case tp @ RefinedType(parent, name) => val parent1 = elim(tp.parent) - tp.info match { + tp.refinedInfo match { case TypeAlias(info: TypeRefBySym) if boundSyms contains info.fixedSym => RefinedType(parent1, name, info.fixedSym.info) case info: TypeRefBySym if boundSyms contains info.fixedSym => |