@@ -116,9 +116,9 @@ object Parsers {
116116 /** Issue an error at given offset if beyond last error offset
117117 * and update lastErrorOffset.
118118 */
119- def syntaxError (msg : => Message , offset : Int = in.offset): Unit =
119+ def syntaxError (msg : => Message , offset : Int = in.offset, name : Name = in.name ): Unit =
120120 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
122122 syntaxError(msg, Position (offset, offset + length))
123123 lastErrorOffset = in.offset
124124 }
@@ -730,11 +730,16 @@ object Parsers {
730730 def typ (): Tree = {
731731 val start = in.offset
732732 val isImplicit = in.token == IMPLICIT
733+ var isImplicitFun = false
733734 if (isImplicit) in.nextToken()
734735 def functionRest (params : List [Tree ]): Tree =
735736 atPos(start, accept(ARROW )) {
736737 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)
738743 }
739744 val t =
740745 if (in.token == LPAREN ) {
@@ -771,6 +776,9 @@ object Parsers {
771776 }
772777 else infixType()
773778
779+ if (isImplicit && ! isImplicitFun && in.token != ARROW )
780+ syntaxError(" Types with implicit keyword can only be function types" , start, nme.IMPLICITkw )
781+
774782 in.token match {
775783 case ARROW => functionRest(t :: Nil )
776784 case FORSOME => syntaxError(ExistentialTypesNoLongerSupported ()); t
0 commit comments