diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 27 | ||||
-rw-r--r-- | test/dotc/tests.scala | 1 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 358f20510..9eded7900 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -45,14 +45,21 @@ object Implicits { protected def filterMatching(pt: Type)(implicit ctx: Context): List[TermRef] = track("filterMatching") { def refMatches(ref: TermRef)(implicit ctx: Context) = { - + def discardForView(tpw: Type, argType: Type): Boolean = tpw match { - case tpw: MethodType => - tpw.isImplicit || - tpw.paramTypes.length != 1 || - !(argType <:< tpw.paramTypes.head)(ctx.fresh.withExploreTyperState) - case tpw: PolyType => - discardForView((new WildApprox) apply tpw.resultType, argType) + case mt: MethodType => + mt.isImplicit || + mt.paramTypes.length != 1 || + !(argType <:< mt.paramTypes.head)(ctx.fresh.withExploreTyperState) + case poly: PolyType => + poly.resultType match { + case mt: MethodType => + mt.isImplicit || + mt.paramTypes.length != 1 || + !(argType <:< ((new WildApprox) apply mt.paramTypes.head))(ctx.fresh.withExploreTyperState) + case rtp => + discardForView((new WildApprox) apply rtp, argType) + } case tpw: TermRef => false // can't discard overloaded refs case tpw => @@ -65,7 +72,7 @@ object Implicits { true } } - + def discardForValueType(tpw: Type): Boolean = tpw match { case mt: MethodType => !mt.isImplicit case mt: PolyType => discardForValueType(tpw.resultType) @@ -74,7 +81,7 @@ object Implicits { def discard = pt match { case pt: ViewProto => discardForView(ref.widen, pt.argType) - case _: ValueType => !defn.isFunctionType(pt) && discardForValueType(ref.widen) + case _: ValueType => !defn.isFunctionType(pt) && discardForValueType(ref.widen) case _ => false } @@ -146,7 +153,7 @@ object Implicits { } } - private def computeEligible(tp: Type): List[TermRef] = ctx.traceIndented(i"computeEligible $tp in $refs%, %", implicitsDetailed) { + private def computeEligible(tp: Type): List[TermRef] = /*>|>*/ ctx.traceIndented(i"computeEligible $tp in $refs%, %", implicitsDetailed) /*<|<*/ { if (monitored) record(s"check eligible refs in ctx", refs.length) val ownEligible = filterMatching(tp) if (outerCtx == NoContext) ownEligible diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 35e00a5d1..0b36fb810 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -43,6 +43,7 @@ class tests extends CompilerTest { @Test def neg_typedidents() = compileFile(negDir, "typedidents", xerrors = 2) @Test def neg_assignments() = compileFile(negDir, "assignments", xerrors = 3) @Test def neg_typers() = compileFile(negDir, "typers", xerrors = 10) + //@Test def neg_rootImports = compileFile(negDir, "rootImplicits", xerrors = 2) @Test def dotc = compileDir(dotcDir + "tools/dotc") @Test def dotc_ast = compileDir(dotcDir + "tools/dotc/ast") |