Skip to content

Commit

Permalink
Renaming: typeConstructor -> typeRef
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Nov 22, 2013
1 parent 3d98269 commit 9e1bf77
Show file tree
Hide file tree
Showing 21 changed files with 191 additions and 192 deletions.
12 changes: 6 additions & 6 deletions src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ object desugar {
}
else Nil

def anyRef = ref(defn.AnyRefAlias.typeConstructor)
def anyRef = ref(defn.AnyRefAlias.typeRef)
def parentConstr(tpt: Tree) = Select(New(tpt), nme.CONSTRUCTOR)

val parents1 = if (parents.isEmpty) parentConstr(anyRef) :: Nil else parents
Expand Down Expand Up @@ -314,7 +314,7 @@ object desugar {
}

def makeAnnotated(cls: Symbol, tree: Tree)(implicit ctx: Context) =
Annotated(TypedSplice(tpd.New(cls.typeConstructor)), tree)
Annotated(TypedSplice(tpd.New(cls.typeRef)), tree)

private def derivedValDef(mods: Modifiers, named: NameTree, tpt: Tree, rhs: Tree) =
ValDef(mods, named.name.asTermName, tpt, rhs).withPos(named.pos)
Expand Down Expand Up @@ -509,7 +509,7 @@ object desugar {
// begin desugar
tree match {
case SymbolLit(str) =>
New(ref(defn.SymbolClass.typeConstructor), (Literal(Constant(str)) :: Nil) :: Nil)
New(ref(defn.SymbolClass.typeRef), (Literal(Constant(str)) :: Nil) :: Nil)
case InterpolatedString(id, strs, elems) =>
Apply(Select(Apply(Ident(nme.StringContext), strs), id), elems)
case InfixOp(l, op, r) =>
Expand All @@ -528,15 +528,15 @@ object desugar {
}
case PrefixOp(op, t) =>
if ((ctx.mode is Mode.Type) && op == nme.ARROWkw)
AppliedTypeTree(ref(defn.ByNameParamClass.typeConstructor), t)
AppliedTypeTree(ref(defn.ByNameParamClass.typeRef), t)
else
Select(t, nme.UNARY_PREFIX ++ op)
case Parens(t) =>
t
case Tuple(ts) =>
if (unboxedPairs) {
def PairTypeTree(l: Tree, r: Tree) =
AppliedTypeTree(ref(defn.PairClass.typeConstructor), l :: r :: Nil)
AppliedTypeTree(ref(defn.PairClass.typeRef), l :: r :: Nil)
if (ctx.mode is Mode.Type) ts.reduceRight(PairTypeTree)
else if (ts.isEmpty) unitLiteral
else ts.reduceRight(Pair(_, _))
Expand All @@ -549,7 +549,7 @@ object desugar {
unitLiteral
}
else if (arity == 1) ts.head
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleClass.typeConstructor), ts)
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleClass.typeRef), ts)
else if (arity == 0) unitLiteral
else Apply(ref(tupleClass.companionModule.symRef), ts)
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ trait TreeInfo[T >: Untyped] { self: Trees.Instance[T] =>

/** Does this CaseDef catch Throwable? */
def catchesThrowable(cdef: CaseDef)(implicit ctx: Context) =
catchesAllOf(cdef, defn.ThrowableClass.typeConstructor)
catchesAllOf(cdef, defn.ThrowableClass.typeRef)

/** Does this CaseDef catch everything of a certain Type? */
def catchesAllOf(cdef: CaseDef, threshold: Type)(implicit ctx: Context) =
Expand Down
8 changes: 4 additions & 4 deletions src/dotty/tools/dotc/ast/TypedTrees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {

def SeqLiteral(elems: List[Tree])(implicit ctx: Context): SeqLiteral =
untpd.SeqLiteral(elems)
.withType(defn.SeqClass.typeConstructor.appliedTo(ctx.typeComparer.lub(elems.tpes)))
.withType(defn.SeqClass.typeRef.appliedTo(ctx.typeComparer.lub(elems.tpes)))
.checked

def SeqLiteral(tpe: Type, elems: List[Tree])(implicit ctx: Context): SeqLiteral = {
Expand All @@ -160,7 +160,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {

def JavaSeqLiteral(elems: List[Tree])(implicit ctx: Context): SeqLiteral =
new untpd.JavaSeqLiteral(elems)
.withType(defn.ArrayClass.typeConstructor.appliedTo(ctx.typeComparer.lub(elems.tpes)))
.withType(defn.ArrayClass.typeRef.appliedTo(ctx.typeComparer.lub(elems.tpes)))
.checked

def TypeTree(original: Tree)(implicit ctx: Context): TypeTree =
Expand Down Expand Up @@ -225,7 +225,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val (tparams, mtp) = sym.info match {
case tp: PolyType =>
val tparams = ctx.newTypeParams(sym, tp.paramNames, EmptyFlags, tp.instantiateBounds)
(tparams, tp.instantiate(tparams map (_.typeConstructor)))
(tparams, tp.instantiate(tparams map (_.typeRef)))
case tp => (Nil, tp)
}

Expand Down Expand Up @@ -346,7 +346,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val modcls = sym.moduleClass.asClass
val constr = DefDef(modcls.primaryConstructor.asTerm, EmptyTree)
val clsdef = ClassDef(modcls, constr, body)
val valdef = ValDef(sym, New(modcls.typeConstructor))
val valdef = ValDef(sym, New(modcls.typeRef))
Thicket(valdef, clsdef)
}

Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/UntypedTrees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ object untpd extends Trees.Instance[Untyped] with TreeInfo[Untyped] {
def ref(tp: NamedType)(implicit ctx: Context): Tree =
TypedSplice(tpd.ref(tp))

def scalaUnit(implicit ctx: Context) = ref(defn.UnitClass.typeConstructor)
def scalaUnit(implicit ctx: Context) = ref(defn.UnitClass.typeRef)

def makeConstructor(mods: Modifiers, tparams: List[TypeDef], vparamss: List[List[ValDef]], rhs: Tree = EmptyTree)(implicit ctx: Context): DefDef =
DefDef(mods, nme.CONSTRUCTOR, tparams, vparamss, TypeTree(), rhs)
Expand Down
8 changes: 4 additions & 4 deletions src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object Annotations {
apply(cls, arg1 :: arg2 :: Nil)

def apply(cls: ClassSymbol, args: List[Tree])(implicit ctx: Context): Annotation =
apply(cls.typeConstructor, args)
apply(cls.typeRef, args)

def apply(atp: Type, arg: Tree)(implicit ctx: Context): Annotation =
apply(atp, arg :: Nil)
Expand All @@ -58,11 +58,11 @@ object Annotations {
apply(defn.AliasAnnot, List(Ident(TermRef.withSig(sym.owner.thisType, sym.name, sym.signature).withDenot(sym))))

def makeChild(sym: Symbol)(implicit ctx: Context) =
apply(defn.ChildAnnot.typeConstructor.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil)
apply(defn.ChildAnnot.typeRef.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil)
}

def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context) = {
val tref = cls.symTypeRef
Annotation(defn.ThrowsAnnot.typeConstructor.appliedTo(tref), Ident(tref))
val tref = cls.typeRef
Annotation(defn.ThrowsAnnot.typeRef.appliedTo(tref), Ident(tref))
}
}
22 changes: 11 additions & 11 deletions src/dotty/tools/dotc/core/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ object Constants {
def isAnyVal = UnitTag <= tag && tag <= DoubleTag

def tpe(implicit ctx: Context): Type = tag match {
case UnitTag => defn.UnitClass.typeConstructor
case BooleanTag => defn.BooleanClass.typeConstructor
case ByteTag => defn.ByteClass.typeConstructor
case ShortTag => defn.ShortClass.typeConstructor
case CharTag => defn.CharClass.typeConstructor
case IntTag => defn.IntClass.typeConstructor
case LongTag => defn.LongClass.typeConstructor
case FloatTag => defn.FloatClass.typeConstructor
case DoubleTag => defn.DoubleClass.typeConstructor
case StringTag => defn.StringClass.typeConstructor
case NullTag => defn.NullClass.typeConstructor
case UnitTag => defn.UnitClass.typeRef
case BooleanTag => defn.BooleanClass.typeRef
case ByteTag => defn.ByteClass.typeRef
case ShortTag => defn.ShortClass.typeRef
case CharTag => defn.CharClass.typeRef
case IntTag => defn.IntClass.typeRef
case LongTag => defn.LongClass.typeRef
case FloatTag => defn.FloatClass.typeRef
case DoubleTag => defn.DoubleClass.typeRef
case StringTag => defn.StringClass.typeRef
case NullTag => defn.NullClass.typeRef
case ClazzTag => defn.ClassType(typeValue)
case EnumTag => defn.EnumType(symbolValue)
}
Expand Down
72 changes: 36 additions & 36 deletions src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ class Definitions(implicit ctx: Context) {
lazy val NotNullClass = requiredClass("scala.NotNull")

lazy val NothingClass: ClassSymbol = newCompleteClassSymbol(
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeConstructor))
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef))
lazy val NullClass: ClassSymbol = newCompleteClassSymbol(
ScalaPackageClass, tpnme.Null, AbstractFinal, List(AnyRefAlias.typeConstructor))
ScalaPackageClass, tpnme.Null, AbstractFinal, List(AnyRefAlias.typeRef))

lazy val PredefModule = requiredModule("scala.Predef")
lazy val NilModule = requiredModule("scala.collection.immutable.Nil")
Expand All @@ -157,7 +157,7 @@ class Definitions(implicit ctx: Context) {
// but does not define it as an explicit class.
newCompleteClassSymbol(
ScalaPackageClass, tpnme.Singleton, Trait | Interface | Final,
List(AnyClass.typeConstructor), EmptyScope)
List(AnyClass.typeRef), EmptyScope)
lazy val SeqClass: ClassSymbol = requiredClass("scala.collection.Seq")
lazy val ArrayClass: ClassSymbol = requiredClass("scala.Array")
lazy val uncheckedStableClass: ClassSymbol = requiredClass("scala.annotation.unchecked.uncheckedStable")
Expand Down Expand Up @@ -235,35 +235,35 @@ class Definitions(implicit ctx: Context) {
def methOfAnyRef(tp: Type) = MethodType(List(AnyRefType), tp)

// Derived types
def AnyType: Type = AnyClass.typeConstructor
def AnyValType: Type = AnyValClass.typeConstructor
def ObjectType: Type = ObjectClass.typeConstructor
def AnyRefType: Type = AnyRefAlias.typeConstructor
def NotNullType: Type = NotNullClass.typeConstructor
def NothingType: Type = NothingClass.typeConstructor
def NullType: Type = NullClass.typeConstructor
def SeqType: Type = SeqClass.typeConstructor
def ArrayType: Type = ArrayClass.typeConstructor
def AnyType: Type = AnyClass.typeRef
def AnyValType: Type = AnyValClass.typeRef
def ObjectType: Type = ObjectClass.typeRef
def AnyRefType: Type = AnyRefAlias.typeRef
def NotNullType: Type = NotNullClass.typeRef
def NothingType: Type = NothingClass.typeRef
def NullType: Type = NullClass.typeRef
def SeqType: Type = SeqClass.typeRef
def ArrayType: Type = ArrayClass.typeRef
def ObjectArrayType = ArrayType.appliedTo(ObjectType)

def UnitType: Type = UnitClass.typeConstructor
def BooleanType: Type = BooleanClass.typeConstructor
def ByteType: Type = ByteClass.typeConstructor
def ShortType: Type = ShortClass.typeConstructor
def CharType: Type = CharClass.typeConstructor
def IntType: Type = IntClass.typeConstructor
def LongType: Type = LongClass.typeConstructor
def FloatType: Type = FloatClass.typeConstructor
def DoubleType: Type = DoubleClass.typeConstructor
def PairType: Type = PairClass.typeConstructor
def StringType: Type = StringClass.typeConstructor
def RepeatedParamType = RepeatedParamClass.typeConstructor
def JavaRepeatedParamType = JavaRepeatedParamClass.typeConstructor
def ThrowableType = ThrowableClass.typeConstructor
def OptionType = OptionClass.typeConstructor
def UnitType: Type = UnitClass.typeRef
def BooleanType: Type = BooleanClass.typeRef
def ByteType: Type = ByteClass.typeRef
def ShortType: Type = ShortClass.typeRef
def CharType: Type = CharClass.typeRef
def IntType: Type = IntClass.typeRef
def LongType: Type = LongClass.typeRef
def FloatType: Type = FloatClass.typeRef
def DoubleType: Type = DoubleClass.typeRef
def PairType: Type = PairClass.typeRef
def StringType: Type = StringClass.typeRef
def RepeatedParamType = RepeatedParamClass.typeRef
def JavaRepeatedParamType = JavaRepeatedParamClass.typeRef
def ThrowableType = ThrowableClass.typeRef
def OptionType = OptionClass.typeRef

def ClassType(arg: Type)(implicit ctx: Context) = {
val ctype = ClassClass.typeConstructor
val ctype = ClassClass.typeRef
if (ctx.phase.erasedTypes) ctype else ctype.appliedTo(arg)
}

Expand All @@ -273,11 +273,11 @@ class Definitions(implicit ctx: Context) {
// - sym: the symbol of the actual enumeration value (VAL1)
// - .owner: the ModuleClassSymbol of the enumeration (object E)
// - .linkedClass: the ClassSymbol of the enumeration (class E)
sym.owner.linkedClass.typeConstructor
sym.owner.linkedClass.typeRef

object FunctionType {
def apply(args: List[Type], resultType: Type) =
FunctionClass(args.length).typeConstructor.appliedTo(args :+ resultType)
FunctionClass(args.length).typeRef.appliedTo(args :+ resultType)
def unapply(ft: Type) = {
val tsym = ft.typeSymbol
lazy val targs = ft.typeArgs
Expand Down Expand Up @@ -362,7 +362,7 @@ class Definitions(implicit ctx: Context) {
val paramDecls = newScope
for ((v, i) <- vcs.zipWithIndex)
newTypeParam(cls, tpnme.higherKindedParamName(i), varianceFlags(v), paramDecls)
denot.info = ClassInfo(ScalaPackageClass.thisType, cls, List(ObjectClass.typeConstructor), paramDecls)
denot.info = ClassInfo(ScalaPackageClass.thisType, cls, List(ObjectClass.typeRef), paramDecls)
}
}

Expand Down Expand Up @@ -657,8 +657,8 @@ class Definitions(implicit ctx: Context) {
// convenient one-argument parameter lists
lazy val anyparam = List(AnyClass.tpe)
lazy val anyvalparam = List(AnyValClass.typeConstructor)
lazy val anyrefparam = List(AnyRefClass.typeConstructor)
lazy val anyvalparam = List(AnyValClass.typeRef)
lazy val anyrefparam = List(AnyRefClass.typeRef)
// private parameter conveniences
private def booltype = BooleanClass.tpe
Expand Down Expand Up @@ -1205,7 +1205,7 @@ class Definitions(implicit ctx: Context) {
/** Given type U, creates a Type representing Class[_ <: U].
*/
def boundedClassType(upperBound: Type) =
appliedTypeAsUpperBounds(ClassClass.typeConstructor, List(upperBound))
appliedTypeAsUpperBounds(ClassClass.typeRef, List(upperBound))
/** To avoid unchecked warnings on polymorphic classes, translate
* a Foo[T] into a Foo[_] for use in the pattern matcher.
Expand Down Expand Up @@ -1262,7 +1262,7 @@ class Definitions(implicit ctx: Context) {
// java.lang.Object. Java also special cases the return type.
lazy val Any_getClass = enterNewMethod(AnyClass, nme.getClass_, Nil, requiredMethod(ObjectClass, nme.getClass_).tpe.resultType, DEFERRED)
lazy val Any_isInstanceOf = newT1NullaryMethod(AnyClass, nme.isInstanceOf_, Final)(_ => BooleanType)
lazy val Any_asInstanceOf = newT1NullaryMethod(AnyClass, nme.asInstanceOf_, Final)(_.typeConstructor)
lazy val Any_asInstanceOf = newT1NullaryMethod(AnyClass, nme.asInstanceOf_, Final)(_.typeRef)
// A type function from T => Class[U], used to determine the return
// type of getClass calls. The returned type is:
Expand Down Expand Up @@ -1692,7 +1692,7 @@ class Definitions(implicit ctx: Context) {
// TODO: set type bounds manually (-> MulticastDelegate), see newTypeParam
val newCaller = enterNewMethod(DelegateClass, name, paramTypes, delegateType, Final | STATIC)
// val newCaller = newPolyMethod(DelegateClass, name,
// tparam => MethodType(paramTypes, tparam.typeConstructor)) setFlag (Final | STATIC)
// tparam => MethodType(paramTypes, tparam.typeRef)) setFlag (Final | STATIC)
Delegate_scalaCallers = Delegate_scalaCallers ::: List(newCaller)
nbScalaCallers += 1
newCaller
Expand Down
8 changes: 4 additions & 4 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ object SymDenotations {
/** The named typeref representing the type constructor for this type.
* @throws ClassCastException is this is not a type
*/
def typeConstructor(implicit ctx: Context): TypeRef =
def typeRef(implicit ctx: Context): TypeRef =
if ((this is PackageClass) || owner.isTerm) symTypeRef
else TypeRef(owner.thisType, name.asTypeName).withDenot(this)

Expand Down Expand Up @@ -779,8 +779,8 @@ object SymDenotations {

private[this] var myTypeConstructor: TypeRef = null

override def typeConstructor(implicit ctx: Context): TypeRef = {
if (myTypeConstructor == null) myTypeConstructor = super.typeConstructor
override def typeRef(implicit ctx: Context): TypeRef = {
if (myTypeConstructor == null) myTypeConstructor = super.typeRef
myTypeConstructor
}

Expand Down Expand Up @@ -1003,7 +1003,7 @@ object SymDenotations {

ctx.debugTraceIndented(s"$tp.baseType($this)") {
if (symbol.isStatic && tp.derivesFrom(symbol))
symbol.typeConstructor
symbol.typeRef
else tp match {
case tp: CachedType =>
if (baseTypeValid != ctx.runId) {
Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ trait Symbols { this: Context =>

/** Create a class constructor symbol for given class `cls`. */
def newConstructor(cls: ClassSymbol, flags: FlagSet, paramNames: List[TermName], paramTypes: List[Type], privateWithin: Symbol = NoSymbol, coord: Coord = NoCoord) =
newSymbol(cls, nme.CONSTRUCTOR, flags | Method, MethodType(paramNames, paramTypes)(_ => cls.typeConstructor), privateWithin, coord)
newSymbol(cls, nme.CONSTRUCTOR, flags | Method, MethodType(paramNames, paramTypes)(_ => cls.typeRef), privateWithin, coord)

/** Create an empty default constructor symbol for given class `cls`. */
def newDefaultConstructor(cls: ClassSymbol) =
Expand Down Expand Up @@ -463,7 +463,7 @@ object Symbols {

override def superId(implicit ctx: Context): Int = {
val hint = superIdHint
val key = this.typeConstructor
val key = this.typeRef
if (hint >= 0 && hint <= ctx.lastSuperId && (ctx.classOfId(hint) eq key))
hint
else {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class TypeComparer(initctx: Context) extends DotClass {
((v > 0) || (lo2 isRef NothingClass) || isSubType(lo2, lo1)) &&
((v < 0) || (hi2 isRef AnyClass) || isSubType(hi1, hi2))
case tp1: ClassInfo =>
val tt = tp1.typeConstructor // was typeTemplate
val tt = tp1.typeRef
isSubType(lo2, tt) && isSubType(tt, hi2)
case _ =>
false
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ trait TypeOps { this: Context =>
case tp: TypeRef =>
tp
case ErrorType =>
defn.AnyClass.typeConstructor
defn.AnyClass.typeRef
case _ =>
throw new TypeError(s"unexpected parent type: $tp")
}
Expand Down
Loading

0 comments on commit 9e1bf77

Please sign in to comment.