@@ -3053,18 +3053,25 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3053
3053
if sym.isOpaqueAlias then
3054
3054
checkFullyAppliedType(rhs1, " Opaque type alias must be fully applied, but " )
3055
3055
checkNoContextFunctionType(rhs1)
3056
+ var attachCap = false
3056
3057
if Feature .ccEnabled then
3057
3058
val isCap = tdef.hasAttachment(CaptureVar )
3058
3059
rhs1 match
3059
3060
case TypeBoundsTree (lo, hi, _) =>
3060
- if ! isCap && (lo.tpe.derivesFrom(defn.Caps_CapSet ) ^ hi.tpe.derivesFrom(defn.Caps_CapSet )) then
3061
+ val loIsCap = lo.tpe.derivesFrom(defn.Caps_CapSet )
3062
+ val hiIsCap = hi.tpe.derivesFrom(defn.Caps_CapSet )
3063
+ if ! isCap && (loIsCap ^ hiIsCap) then
3061
3064
report.error(em " Illegal type bounds: >: $lo <: $hi. Capture-set bounds cannot be mixed with type bounds of other kinds " , rhs.srcPos)
3062
- if isCap && ! (lo.tpe.derivesFrom(defn. Caps_CapSet ) && hi.tpe.derivesFrom(defn. Caps_CapSet ) ) then
3065
+ if isCap && ! (loIsCap && hiIsCap ) then
3063
3066
report.error(em " Illegal type bounds: >: $lo <: $hi. $name^ can only have capture sets as bounds " , rhs.srcPos)
3067
+ attachCap = ! isCap && loIsCap && hiIsCap
3064
3068
case LambdaTypeTree (_, _) if isCap =>
3065
3069
report.error(em " ` $name` cannot have type parameters, because it ranges over capture sets " , rhs.srcPos)
3066
3070
case _ =>
3067
- assignType(cpy.TypeDef (tdef)(name, rhs1), sym)
3071
+ val res = assignType(cpy.TypeDef (tdef)(name, rhs1), sym)
3072
+ if Feature .ccEnabled && attachCap then
3073
+ res.putAttachment(CaptureVar , ())
3074
+ res
3068
3075
}
3069
3076
3070
3077
def typedClassDef (cdef : untpd.TypeDef , cls : ClassSymbol )(using Context ): Tree = ctx.profiler.onTypedDef(cls) {
0 commit comments