aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-09-26 12:03:10 +0200
committerMartin Odersky <odersky@gmail.com>2013-09-26 12:43:55 +0200
commit54acd26dcf377e2eb2a474399894e10cfd4322f5 (patch)
treea275062a8cab9e81b401a4745400f8db71fed1ae /src/dotty/tools/dotc/typer
parentb7f5aa30383730dc1d2b34f9773695d0f5669bcd (diff)
downloaddotty-54acd26dcf377e2eb2a474399894e10cfd4322f5.tar.gz
dotty-54acd26dcf377e2eb2a474399894e10cfd4322f5.tar.bz2
dotty-54acd26dcf377e2eb2a474399894e10cfd4322f5.zip
Added isRef method to determine whether a type is a typeref that refers to a symbol.
The alternative (tpe eq sym.typeConstructor) does not work because types are not unique. The alternative (tpe.typeSymbol == sym) does not work because other types than TypeRefs have typeSymbols.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--src/dotty/tools/dotc/typer/EtaExpansion.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala6
4 files changed, 6 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index f81fcf3cd..bf49091ec 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -556,7 +556,7 @@ trait Applications extends Compatibility { self: Typer =>
if (tp derivesFrom defn.ProductClass) productSelectors
else if (tp derivesFrom defn.SeqClass) seqSelector :: Nil
- else if (tp.typeSymbol == defn.BooleanClass) Nil
+ else if (tp isRef defn.BooleanClass) Nil
else if (extractorMemberType(nme.isDefined).exists &&
extractorMemberType(nme.get).exists) recur(extractorMemberType(nme.get))
else {
diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 6a2b2060e..155574c81 100644
--- a/src/dotty/tools/dotc/typer/EtaExpansion.scala
+++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala
@@ -31,11 +31,10 @@ object EtaExpansion {
def liftArgs(defs: mutable.ListBuffer[Tree], methType: Type, args: List[Tree])(implicit ctx: Context) = {
def toPrefix(name: Name) = if (name contains '$') "" else name.toString
- def isByName(tp: Type) = tp.typeSymbol == defn.ByNameParamClass
val paramInfos = methType match {
case MethodType(paramNames, paramTypes) =>
(paramNames, paramTypes).zipped map ((name, tp) =>
- (toPrefix(name), isByName(tp)))
+ (toPrefix(name), tp isRef defn.ByNameParamClass))
case _ =>
args map Function.const(("", false))
}
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index 7a8b94571..2137981e7 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -28,7 +28,7 @@ object Inferencing {
*/
def isCompatible(tp: Type, pt: Type)(implicit ctx: Context): Boolean = (
(tp <:< pt)
- || pt.typeSymbol == defn.ByNameParamClass && (tp <:< pt.typeArgs.head)
+ || (pt isRef defn.ByNameParamClass) && (tp <:< pt.typeArgs.head)
|| viewExists(tp, pt))
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 69b79a474..0c33aa026 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -387,7 +387,7 @@ class Typer extends Namer with Applications with Implicits {
def typedPair(tree: untpd.Pair, pt: Type)(implicit ctx: Context) = {
val (leftProto, rightProto) = pt.typeArgs match {
- case l :: r :: Nil if pt.typeSymbol == defn.PairClass => (l, r)
+ case l :: r :: Nil if pt isRef defn.PairClass => (l, r)
case _ => (WildcardType, WildcardType)
}
val left1 = typed(tree.left, leftProto)
@@ -468,7 +468,7 @@ class Typer extends Namer with Applications with Implicits {
else {
val params = args.asInstanceOf[List[ValDef]]
val protoFormals: List[Type] = pt match {
- case _ if pt.typeSymbol == defn.FunctionClass(params.length) =>
+ case _ if pt isRef defn.FunctionClass(params.length) =>
pt.typeArgs take params.length
case SAMType(meth) =>
val MethodType(_, paramTypes) = meth.info
@@ -1028,7 +1028,7 @@ class Typer extends Namer with Applications with Implicits {
val folded = ConstFold(tree, pt)
if (folded ne EmptyTree) return folded
// drop type if prototype is Unit
- if (pt.typeSymbol == defn.UnitClass)
+ if (pt isRef defn.UnitClass)
return tpd.Block(tree :: Nil, Literal(Constant()))
// convert function literal to SAM closure
tree match {