@@ -116,9 +116,9 @@ object Parsers {
116
116
/** Issue an error at given offset if beyond last error offset
117
117
* and update lastErrorOffset.
118
118
*/
119
- def syntaxError (msg : => Message , offset : Int = in.offset): Unit =
119
+ def syntaxError (msg : => Message , offset : Int = in.offset, name : Name = in.name ): Unit =
120
120
if (offset > lastErrorOffset) {
121
- val length = if (in. name != null ) in. name.show.length else 0
121
+ val length = if (name != null ) name.show.length else 0
122
122
syntaxError(msg, Position (offset, offset + length))
123
123
lastErrorOffset = in.offset
124
124
}
@@ -730,11 +730,16 @@ object Parsers {
730
730
def typ (): Tree = {
731
731
val start = in.offset
732
732
val isImplicit = in.token == IMPLICIT
733
+ var isImplicitFun = false
733
734
if (isImplicit) in.nextToken()
734
735
def functionRest (params : List [Tree ]): Tree =
735
736
atPos(start, accept(ARROW )) {
736
737
val t = typ()
737
- if (isImplicit) new ImplicitFunction (params, t) else Function (params, t)
738
+ if (isImplicit) {
739
+ isImplicitFun = true
740
+ new ImplicitFunction (params, t)
741
+ }
742
+ else Function (params, t)
738
743
}
739
744
val t =
740
745
if (in.token == LPAREN ) {
@@ -771,6 +776,9 @@ object Parsers {
771
776
}
772
777
else infixType()
773
778
779
+ if (isImplicit && ! isImplicitFun && in.token != ARROW )
780
+ syntaxError(" Types with implicit keyword can only be function types" , start, nme.IMPLICITkw )
781
+
774
782
in.token match {
775
783
case ARROW => functionRest(t :: Nil )
776
784
case FORSOME => syntaxError(ExistentialTypesNoLongerSupported ()); t
0 commit comments