aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-20 14:50:51 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-20 14:50:51 +0100
commit608fbca82816c6b43def0b38de5f93133954e8ae (patch)
tree0cdce44f110c058d311529f0989b4d5d7316e747 /src/dotty/tools/dotc/typer
parent0a8c17efca37e14b8467d7da9ffd6c48c8cd1c0f (diff)
downloaddotty-608fbca82816c6b43def0b38de5f93133954e8ae.tar.gz
dotty-608fbca82816c6b43def0b38de5f93133954e8ae.tar.bz2
dotty-608fbca82816c6b43def0b38de5f93133954e8ae.zip
For a typeRef, prefer info.isAlias over symbol.isAliasType
Reason: This works even for typeRefs with joint-ref denotations, even if the symbol does not exist. The only reason to use symbol.isAliasType is if info.isAlias can produce a cycle.
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/Implicits.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala13
3 files changed, 5 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 1ee34e4be..0969562da 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -544,7 +544,7 @@ trait Applications extends Compatibility { self: Typer =>
case tree: untpd.RefTree =>
val ttree = typedType(tree.withName(tree.name.toTypeName))
ttree.tpe match {
- case alias: TypeRef if alias.symbol.isAliasType =>
+ case alias: TypeRef if alias.info.isAlias =>
companionRef(alias) match {
case companion: TermRef => return untpd.ref(companion) withPos tree.pos
case _ =>
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 9cc472ba4..10ba90055 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -485,7 +485,7 @@ class SearchHistory(val searchDepth: Int, val seen: Map[ClassSymbol, Int]) {
def apply(n: Int, tp: Type): Int = tp match {
case tp: RefinedType =>
foldOver(n + 1, tp)
- case tp: TypeRef if tp.symbol.isAliasType =>
+ case tp: TypeRef if tp.info.isAlias =>
apply(n, tp.info.bounds.hi)
case _ =>
foldOver(n, tp)
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index fba2201bf..6e522b831 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -305,16 +305,9 @@ object Inferencing {
inst
}
private var toMaximize: Boolean = false
- def apply(x: Boolean, tp: Type): Boolean = tp match {
+ def apply(x: Boolean, tp: Type): Boolean = tp.dealias match {
case _: WildcardType =>
false
- case tp: TypeRef =>
- // todo: factor out? same logic is also used in avoid.
- // and interestingly it does not work with #dealias
- tp.info match {
- case TypeAlias(ref) => apply(x, ref)
- case _ => foldOver(x, tp)
- }
case tvar: TypeVar if !tvar.isInstantiated =>
if (force == ForceDegree.none) false
else {
@@ -324,9 +317,9 @@ object Inferencing {
isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true)))
if (minimize) instantiate(tvar, fromBelow = true)
else toMaximize = true
- foldOver(x, tp)
+ foldOver(x, tvar)
}
- case _ =>
+ case tp =>
foldOver(x, tp)
}