aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/Types.scala23
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
2 files changed, 16 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index f27822639..904e11399 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1092,9 +1092,6 @@ object Types {
case None =>
vmap updated (t, variance)
}
- case t: TypeRef =>
- val t1 = t.losslessDealias
- if (t1 ne t) apply(vmap, t1) else foldOver(vmap, t)
case _ =>
foldOver(vmap, t)
}
@@ -1112,9 +1109,6 @@ object Types {
def simplified(implicit ctx: Context) = {
class Simplify extends TypeMap {
def apply(tp: Type): Type = tp match {
- case tp: TypeRef =>
- val tp1 = tp.losslessDealias
- if (tp1 ne tp) apply(tp1) else mapOver(tp)
case AndType(l, r) =>
mapOver(l) & mapOver(r)
case OrType(l, r) =>
@@ -1447,10 +1441,13 @@ object Types {
def isRefinedIn(tp: Type, name: Name): Boolean = tp match {
case RefinedType(parent, refinedName) =>
name == refinedName || isRefinedIn(parent, name)
+ case tp: SingletonType =>
+ isRefinedIn(tp.widen, name)
case _ =>
false
}
- if ((symbol is TypeArgument) || isRefinedIn(prefix, name))
+ if (knownDenotation &&
+ ((symbol is TypeArgument | TypeParam) || isRefinedIn(prefix, name)))
info match {
case TypeBounds(lo, hi) if lo eq hi => hi
case _ => this
@@ -2301,7 +2298,11 @@ object Types {
/** Map this function over given type */
def mapOver(tp: Type): Type = tp match {
- case tp: NamedType =>
+ case tp: TypeRef =>
+ val tp1 = tp.losslessDealias
+ if (tp1 ne tp) this(tp1) else tp.derivedNamedType(this(tp.prefix))
+
+ case tp: TermRef =>
tp.derivedNamedType(this(tp.prefix))
case _: ThisType
@@ -2405,7 +2406,11 @@ object Types {
protected var variance = 1
def foldOver(x: T, tp: Type): T = tp match {
- case tp: NamedType =>
+ case tp: TypeRef =>
+ val tp1 = tp.losslessDealias
+ if (tp1 ne tp) this(x, tp1) else this(x, tp.prefix)
+
+ case tp: TermRef =>
this(x, tp.prefix)
case _: ThisType
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index eec005bc5..14345a627 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -508,10 +508,9 @@ class Typer extends Namer with Applications with Implicits {
val env1 = tree.env mapconserve (typed(_))
val meth1 = typedUnadapted(tree.meth)
val ownType = meth1.tpe.widen match {
- case mt: MethodType if !mt.isDependent =>
- mt.toFunctionType
case mt: MethodType =>
- errorType(i"internal error: cannot turn dependent method type $mt into closure", tree.pos)
+ if (!mt.isDependent) mt.toFunctionType
+ else errorType(i"internal error: cannot turn dependent method type $mt into closure", tree.pos)
case tp =>
errorType(i"internal error: closing over non-method $tp", tree.pos)
}