File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -3140,7 +3140,9 @@ class Typer extends Namer
31403140 if (isFullyDefined(wtp, force = ForceDegree .all) &&
31413141 ctx.typerState.constraint.ne(prevConstraint)) readapt(tree)
31423142 else err.typeMismatch(tree, pt, failure)
3143- if (ctx.mode.is(Mode .ImplicitsEnabled ) && tree.typeOpt.isValueType)
3143+ if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.typeOpt.isValueType then
3144+ if pt.isRef(defn.AnyValClass ) || pt.isRef(defn.ObjectClass ) then
3145+ ctx.error(em " the result of an implicit conversion must be more specific than $pt" , tree.sourcePos)
31443146 inferView(tree, pt) match {
31453147 case SearchSuccess (found : ExtMethodApply , _, _) =>
31463148 found // nothing to check or adapt for extension method applications
Original file line number Diff line number Diff line change 1+ object Test {
2+ val a : AnyVal = " foo" // error
3+ val b : AnyRef = 1 // error
4+ }
You can’t perform that action at this time.
0 commit comments