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
3140
3140
if (isFullyDefined(wtp, force = ForceDegree .all) &&
3141
3141
ctx.typerState.constraint.ne(prevConstraint)) readapt(tree)
3142
3142
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)
3144
3146
inferView(tree, pt) match {
3145
3147
case SearchSuccess (found : ExtMethodApply , _, _) =>
3146
3148
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