diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index ad4eb742fd47..eb8c9eb819be 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3535,7 +3535,9 @@ class Typer extends Namer else err.typeMismatch(tree, pt, failure) if ctx.mode.is(Mode.ImplicitsEnabled) && tree.typeOpt.isValueType then - if pt.isRef(defn.AnyValClass) || pt.isRef(defn.ObjectClass) then + if pt.isRef(defn.AnyValClass, skipRefined = false) + || pt.isRef(defn.ObjectClass, skipRefined = false) + then report.error(em"the result of an implicit conversion must be more specific than $pt", tree.srcPos) inferView(tree, pt) match { case SearchSuccess(found: ExtMethodApply, _, _) => diff --git a/tests/pos/i9403.scala b/tests/pos/i9403.scala new file mode 100644 index 000000000000..0c1c45ba0060 --- /dev/null +++ b/tests/pos/i9403.scala @@ -0,0 +1,9 @@ +import scala.reflect.Selectable.reflectiveSelectable + +object Test { + def main(args: Array[String]): Unit = { + def fCompareToBoolean(x: { def compareTo(y: java.lang.Boolean): Int }, y: Boolean): Int = + x.compareTo(y) + assert(fCompareToBoolean(false, true) < 0) + } +} \ No newline at end of file