aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala8
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala13
2 files changed, 10 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 2d04f7ec1..2519b9a72 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -666,10 +666,6 @@ trait Applications extends Compatibility { self: Typer =>
app.exists && app.hasAltWith(d => isApplicable(TermRef(tp, nme.apply).withDenot(d), args, resultType))
}
- /** Is `tp` a subtype of `pt`? */
- def testCompatible(tp: Type, pt: Type)(implicit ctx: Context) =
- isCompatible(tp, pt)(ctx.fresh.withExploreTyperState)
-
/** In a set of overloaded applicable alternatives, is `alt1` at least as good as
* `alt2`? `alt1` and `alt2` are nonoverloaded references.
*/
@@ -700,7 +696,7 @@ trait Applications extends Compatibility { self: Typer =>
assert(!ctx.typerState.isCommittable)
isAsSpecific(alt1, tp1, alt2, constrained(tp2).resultType)
case _ =>
- testCompatible(tp1, tp2)(ctx)
+ isCompatible(tp1, tp2)
}
}
@@ -833,7 +829,7 @@ trait Applications extends Compatibility { self: Typer =>
narrowByTypes(alts, args, resultType)
case pt =>
- alts filter (alt => testCompatible(normalize(alt), pt))
+ alts filter (normalizedCompatible(_, pt))
}
if (isDetermined(candidates)) candidates
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index a824e95e5..addd3d881 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -33,6 +33,12 @@ object Inferencing {
if (tp isRef defn.ByNameParamClass) tp.typeArgs.head else tp
skipByName(tp) <:< skipByName(pt) || viewExists(tp, pt)
}
+
+ /** Test compatibility after normalization in a fresh typerstate */
+ def normalizedCompatible(tp: Type, pt: Type)(implicit ctx: Context) = {
+ val nestedCtx = ctx.fresh.withExploreTyperState
+ isCompatible(normalize(tp)(nestedCtx), pt)(nestedCtx)
+ }
}
/** A prototype for expressions [] that are part of a selection operation:
@@ -42,14 +48,11 @@ object Inferencing {
class SelectionProto(name: Name, proto: Type)
extends RefinedType(WildcardType, name)(_ => proto) with ProtoType with Compatibility {
override def viewExists(tp: Type, pt: Type)(implicit ctx: Context): Boolean = false
- override def isMatchedBy(tp1: Type)(implicit ctx: Context) = {
- def testCompatible(mbrType: Type)(implicit ctx: Context) =
- isCompatible(normalize(mbrType), proto)
+ override def isMatchedBy(tp1: Type)(implicit ctx: Context) =
name == nme.WILDCARD || {
val mbr = tp1.member(name)
- mbr.exists && mbr.hasAltWith(m => testCompatible(m.info)(ctx.fresh.withExploreTyperState))
+ mbr.exists && mbr.hasAltWith(m => normalizedCompatible(m.info, proto))
}
- }
override def toString = "Proto" + super.toString
}