Skip to content

Don't complain about conversions to refinements of Object and AnyVal #10975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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, _, _) =>
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i9403.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}