@@ -864,6 +864,12 @@ object Parsers {
864864 */
865865 def toplevelTyp (): Tree = rejectWildcardType(typ())
866866
867+ private def isFunction (tree : Tree ): Boolean = tree match {
868+ case Parens (tree1) => isFunction(tree1)
869+ case _ : Function => true
870+ case _ => false
871+ }
872+
867873 /** Type ::= FunType
868874 * | HkTypeParamClause ‘=>>’ Type
869875 * | MatchType
@@ -946,11 +952,11 @@ object Parsers {
946952 val arrowOffset = in.skipToken()
947953 val body = toplevelTyp()
948954 atSpan(start, arrowOffset) {
949- body match {
950- case _ : Function => PolyFunction (tparams, body)
951- case _ =>
952- syntaxError(" Implementation restriction: polymorphic function types must have a value parameter" , arrowOffset)
953- Ident (nme.ERROR .toTypeName)
955+ if (isFunction(body))
956+ PolyFunction (tparams, body)
957+ else {
958+ syntaxError(" Implementation restriction: polymorphic function types must have a value parameter" , arrowOffset)
959+ Ident (nme.ERROR .toTypeName)
954960 }
955961 }
956962 } else { accept(TLARROW ); typ() }
@@ -1381,11 +1387,11 @@ object Parsers {
13811387 val arrowOffset = accept(ARROW )
13821388 val body = expr()
13831389 atSpan(start, arrowOffset) {
1384- body match {
1385- case _ : Function => PolyFunction (tparams, body)
1386- case _ =>
1387- syntaxError(" Implementation restriction: polymorphic function literals must have a value parameter" , arrowOffset)
1388- errorTermTree
1390+ if (isFunction(body))
1391+ PolyFunction (tparams, body)
1392+ else {
1393+ syntaxError(" Implementation restriction: polymorphic function literals must have a value parameter" , arrowOffset)
1394+ errorTermTree
13891395 }
13901396 }
13911397 case _ =>
0 commit comments