@@ -1798,8 +1798,22 @@ object Parsers {
17981798 val start = in.offset
17991799 val tparams = typeParamClause(ParamOwner .Type )
18001800 if in.token == TLARROW then
1801- atSpan(start, in.skipToken()):
1802- LambdaTypeTree (tparams, toplevelTyp())
1801+ val hasContextBounds = tparams.exists(_.rhs match {
1802+ case x : ContextBounds => true
1803+ case _ => false
1804+ })
1805+ if hasContextBounds then
1806+ // Filter illegal context bounds and report syntax error
1807+ atSpan(start, in.skipToken()):
1808+ LambdaTypeTree (tparams.map {
1809+ case TypeDef (name, rhs : ContextBounds ) =>
1810+ syntaxError(em " context bounds are not allowed in type lambdas " , rhs.span)
1811+ TypeDef (name, TypeBoundsTree (EmptyTree , EmptyTree ))
1812+ case other => other
1813+ }, toplevelTyp())
1814+ else
1815+ atSpan(start, in.skipToken()):
1816+ LambdaTypeTree (tparams, toplevelTyp())
18031817 else if in.token == ARROW || isPureArrow(nme.PUREARROW ) then
18041818 val arrowOffset = in.skipToken()
18051819 val body = toplevelTyp(nestedIntoOK(in.token))
@@ -3475,7 +3489,7 @@ object Parsers {
34753489 *
34763490 * HkTypeParamClause ::= ‘[’ HkTypeParam {‘,’ HkTypeParam} ‘]’
34773491 * HkTypeParam ::= {Annotation} [‘+’ | ‘-’]
3478- * (id | ‘_’) [HkTypePamClause ] TypeBounds
3492+ * (id | ‘_’) [HkTypeParamClause ] TypeBounds
34793493 */
34803494 def typeParamClause (paramOwner : ParamOwner ): List [TypeDef ] = inBracketsWithCommas {
34813495
0 commit comments