aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala23
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala9
-rw-r--r--src/dotty/tools/dotc/core/Types.scala7
3 files changed, 22 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 1d2d4bac9..a8ad580a7 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -163,7 +163,8 @@ class TypeComparer(initctx: Context) extends DotClass {
*/
def approximation(param: PolyParam, fromBelow: Boolean): Type = {
val avoidParam = new TypeMap {
- override def apply(tp: Type) = mapOver {
+ override def stopAtStatic = true
+ def apply(tp: Type) = mapOver {
tp match {
case tp: RefinedType if param occursIn tp.refinedInfo => tp.parent
case _ => tp
@@ -269,18 +270,16 @@ class TypeComparer(initctx: Context) extends DotClass {
def compareNamed = tp1 match {
case tp1: NamedType =>
val sym1 = tp1.symbol
- val sym2 = tp2.symbol
- val pre1 = tp1.prefix
- val pre2 = tp2.prefix
-
- ( if (sym1 == sym2) (
- ctx.erasedTypes
+ ( if (sym1 == tp2.symbol) (
+ ctx.erasedTypes
|| sym1.isStaticOwner
- || isSubType(pre1, pre2)
- || pre1.isInstanceOf[ThisType] && pre2.isInstanceOf[ThisType]
- )
- else
- tp1.name == tp2.name && isSubType(pre1, pre2)
+ || { val pre1 = tp1.prefix
+ val pre2 = tp2.prefix
+ isSubType(pre1, pre2) ||
+ pre1.isInstanceOf[ThisType] && pre2.isInstanceOf[ThisType]
+ }
+ ) else
+ tp1.name == tp2.name && isSubType(tp1.prefix, tp2.prefix)
) || secondTryNamed(tp1, tp2)
case _ =>
secondTry(tp1, tp2)
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 6e984e43c..afa39f2a3 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -50,8 +50,11 @@ trait TypeOps { this: Context =>
/** Implementation of Types#simplified */
final def simplify(tp: Type, theMap: SimplifyMap): Type = tp match {
case tp: NamedType =>
- tp.derivedSelect(simplify(tp.prefix, theMap))
- case _: ThisType | NoPrefix =>
+ if (tp.symbol.isStatic) tp
+ else tp.derivedSelect(simplify(tp.prefix, theMap))
+ case tp: PolyParam =>
+ typerState.constraint.typeVarOfParam(tp) orElse tp
+ case _: ThisType | _: BoundType | NoPrefix =>
tp
case tp: RefinedType =>
tp.derivedRefinedType(simplify(tp.parent, theMap), tp.refinedName, simplify(tp.refinedInfo, theMap))
@@ -59,8 +62,6 @@ trait TypeOps { this: Context =>
simplify(l, theMap) & simplify(r, theMap)
case OrType(l, r) =>
simplify(l, theMap) | simplify(r, theMap)
- case tp: PolyParam =>
- typerState.constraint.typeVarOfParam(tp) orElse tp
case _ =>
(if (theMap != null) theMap else new SimplifyMap).mapOver(tp)
}
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index b99162383..bacbe4f9d 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2080,6 +2080,8 @@ object Types {
abstract class TypeMap(implicit ctx: Context) extends (Type => Type) { thisMap =>
+ protected def stopAtStatic = true
+
def apply(tp: Type): Type
protected var variance = 1
@@ -2087,7 +2089,8 @@ object Types {
/** Map this function over given type */
def mapOver(tp: Type): Type = tp match {
case tp: NamedType =>
- tp.derivedSelect(this(tp.prefix))
+ if (stopAtStatic && tp.symbol.isStatic) tp
+ else tp.derivedSelect(this(tp.prefix))
case _: ThisType
| _: BoundType
@@ -2173,6 +2176,7 @@ object Types {
tp.derivedClassInfo(this(tp.prefix))
def andThen(f: Type => Type): TypeMap = new TypeMap {
+ override def stopAtStatic = thisMap.stopAtStatic
def apply(tp: Type) = f(thisMap(tp))
}
}
@@ -2191,6 +2195,7 @@ object Types {
}
object IdentityTypeMap extends TypeMap()(NoContext) {
+ override def stopAtStatic = true
def apply(tp: Type) = tp
}