@@ -68,8 +68,8 @@ object Parsers {
68
68
this == Given || this == ExtensionFollow
69
69
def acceptsVariance =
70
70
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 )
73
73
def acceptsWildcard =
74
74
this == Type || this == Hk
75
75
@@ -3549,11 +3549,16 @@ object Parsers {
3549
3549
else ident().toTypeName
3550
3550
val isCap = gobbleHat()
3551
3551
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)
3557
3562
if isCap then
3558
3563
res.pushAttachment(CaptureVar , ())
3559
3564
// putting the attachment here as well makes post-processing in the typer easier
0 commit comments