Skip to content

Commit 68257a2

Browse files
committed
Don't complain about conversions to refinements of Object and AnyVal
Fixes #9403
1 parent 141bf9e commit 68257a2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3535,7 +3535,9 @@ class Typer extends Namer
35353535
else err.typeMismatch(tree, pt, failure)
35363536

35373537
if ctx.mode.is(Mode.ImplicitsEnabled) && tree.typeOpt.isValueType then
3538-
if pt.isRef(defn.AnyValClass) || pt.isRef(defn.ObjectClass) then
3538+
if pt.isRef(defn.AnyValClass, skipRefined = false)
3539+
|| pt.isRef(defn.ObjectClass, skipRefined = false)
3540+
then
35393541
report.error(em"the result of an implicit conversion must be more specific than $pt", tree.srcPos)
35403542
inferView(tree, pt) match {
35413543
case SearchSuccess(found: ExtMethodApply, _, _) =>

tests/pos/i9403.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.reflect.Selectable.reflectiveSelectable
2+
3+
object Test {
4+
def main(args: Array[String]): Unit = {
5+
def fCompareToBoolean(x: { def compareTo(y: java.lang.Boolean): Int }, y: Boolean): Int =
6+
x.compareTo(y)
7+
assert(fCompareToBoolean(false, true) < 0)
8+
}
9+
}

0 commit comments

Comments
 (0)