@@ -1798,8 +1798,22 @@ object Parsers {
1798
1798
val start = in.offset
1799
1799
val tparams = typeParamClause(ParamOwner .Type )
1800
1800
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())
1803
1817
else if in.token == ARROW || isPureArrow(nme.PUREARROW ) then
1804
1818
val arrowOffset = in.skipToken()
1805
1819
val body = toplevelTyp(nestedIntoOK(in.token))
@@ -3475,7 +3489,7 @@ object Parsers {
3475
3489
*
3476
3490
* HkTypeParamClause ::= ‘[’ HkTypeParam {‘,’ HkTypeParam} ‘]’
3477
3491
* HkTypeParam ::= {Annotation} [‘+’ | ‘-’]
3478
- * (id | ‘_’) [HkTypePamClause ] TypeBounds
3492
+ * (id | ‘_’) [HkTypeParamClause ] TypeBounds
3479
3493
*/
3480
3494
def typeParamClause (paramOwner : ParamOwner ): List [TypeDef ] = inBracketsWithCommas {
3481
3495
0 commit comments