File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -998,11 +998,17 @@ class Namer { typer: Typer =>
998
998
lhsType // keep constant types that fill in for a non-constant (to be revised when inline has landed).
999
999
else inherited
1000
1000
else {
1001
- if (sym is Implicit ) {
1002
- val resStr = if (mdef.isInstanceOf [DefDef ]) " result " else " "
1003
- ctx.error(s " ${resStr}type of implicit definition needs to be given explicitly " , mdef.pos)
1001
+ def missingType (modifier : String ) = {
1002
+ ctx.error(s " ${modifier}type of implicit definition needs to be given explicitly " , mdef.pos)
1004
1003
sym.resetFlag(Implicit )
1004
+
1005
1005
}
1006
+ if (sym is Implicit )
1007
+ mdef match {
1008
+ case _ : DefDef => missingType(" result" )
1009
+ case _ : ValDef if sym.owner.isType => missingType(" " )
1010
+ case _ =>
1011
+ }
1006
1012
lhsType orElse WildcardType
1007
1013
}
1008
1014
}
Original file line number Diff line number Diff line change @@ -6,4 +6,9 @@ object Test {
6
6
7
7
val x : X = Byte .MinValue
8
8
9
+ def foo () = {
10
+ implicit val x = " abc"
11
+ implicitly[String ]
12
+ }
13
+
9
14
}
You can’t perform that action at this time.
0 commit comments