@@ -68,8 +68,8 @@ object Parsers {
6868 this == Given || this == ExtensionFollow
6969 def acceptsVariance =
7070 this == Class || this == CaseClass || this == Hk
71- def acceptsCtxBounds =
72- ! (this == Type || this == Hk )
71+ def acceptsCtxBounds ( using Context ) =
72+ ! (this == Type || this == Hk ) || (sourceVersion.enablesNewGivens && this == Type )
7373 def acceptsWildcard =
7474 this == Type || this == Hk
7575
@@ -3549,11 +3549,16 @@ object Parsers {
35493549 else ident().toTypeName
35503550 val isCap = gobbleHat()
35513551 val hkparams = typeParamClauseOpt(ParamOwner .Hk )
3552- val bounds =
3553- if paramOwner.acceptsCtxBounds then typeAndCtxBounds(name)
3554- else if sourceVersion.enablesNewGivens && paramOwner == ParamOwner .Type then typeAndCtxBounds(name)
3555- else typeBounds()
3556- val res = TypeDef (name, lambdaAbstract(hkparams, bounds)).withMods(mods)
3552+ val bounds = typeAndCtxBounds(name)
3553+ val res = bounds match
3554+ case bounds : TypeBoundsTree =>
3555+ TypeDef (name, lambdaAbstract(hkparams, bounds)).withMods(mods)
3556+ case bounds : ContextBounds if paramOwner.acceptsCtxBounds =>
3557+ TypeDef (name, lambdaAbstract(hkparams, bounds)).withMods(mods)
3558+ case ContextBounds (bounds, cxBounds) =>
3559+ for cbound <- cxBounds do
3560+ report.error(IllegalContextBounds (), cbound.srcPos)
3561+ TypeDef (name, lambdaAbstract(hkparams, bounds)).withMods(mods)
35573562 if isCap then
35583563 res.pushAttachment(CaptureVar , ())
35593564 // putting the attachment here as well makes post-processing in the typer easier
0 commit comments