@@ -927,26 +927,33 @@ trait Implicits:
927927 if currImplicits.outerImplicits == null then currImplicits.refs
928928 else currImplicits.refs ::: allImplicits(currImplicits.outerImplicits)
929929
930+ /** Ensure an implicit is not a Scala 2-style implicit conversion, based on its type */
931+ def notImplicitConv (typ : Type ): Boolean = typ match {
932+ case PolyType (_, resType) => notImplicitConv(resType)
933+ case mt : MethodType => mt.isImplicitMethod || mt.isContextualMethod
934+ case _ => true
935+ }
936+
930937 def ignoredConversions = arg.tpe match
931938 case fail : SearchFailureType =>
932939 // Get every implicit in scope and find Conversions for each
933940 if (fail.expectedType eq pt) || isFullyDefined(fail.expectedType, ForceDegree .none) then
934941 // todo filter out implicit conversions
935- allImplicits(ctx.implicits).map { imp =>
936- // todo imp.underlyingRef.underlying does not work for implicit functions or givens
937- // with type or implicit parameters
938- val impRef = imp.underlyingRef
939- val impResultType = wildApprox(impRef.underlying.finalResultType)
940- val convs = ctx.implicits.eligible(ViewProto (impResultType, fail.expectedType))
941- .filter { conv =>
942- if ! conv.isConversion then false
943- else
944- // Actually feed the summoned implicit into the Conversion to
945- // check if it works
946- true
947- }
948- (impRef, convs.map(_.ref))
949- }.filter(_._2.nonEmpty)
942+ allImplicits(ctx.implicits)
943+ .filter(imp => notImplicitConv( imp.underlyingRef.underlying))
944+ .map { imp =>
945+ val impRef = imp.underlyingRef
946+ val impResultType = wildApprox(impRef.underlying.finalResultType)
947+ val convs = ctx.implicits.eligible(ViewProto (impResultType, fail.expectedType))
948+ .filter { conv =>
949+ if ! conv.isConversion then false
950+ else
951+ // TODO Actually feed the summoned implicit into the Conversion to
952+ // check if it works
953+ true
954+ }
955+ (impRef, convs.map(_.ref))
956+ }.filter(_._2.nonEmpty)
950957 else
951958 Nil
952959
0 commit comments