File tree 2 files changed +14
-3
lines changed
compiler/src/dotty/tools/dotc/typer
tests/neg-custom-args/captures
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -3053,8 +3053,15 @@ 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
- if Feature .ccEnabled && rhs1.tpe.derivesFrom(defn.Caps_CapSet ) then
3057
- rhs1.putAttachment(CaptureVar , ())
3056
+ if Feature .ccEnabled then
3057
+ val isCap = tdef.hasAttachment(CaptureVar )
3058
+ rhs1 match
3059
+ case TypeBoundsTree (lo, hi, _) =>
3060
+ if ! isCap && (lo.tpe.derivesFrom(defn.Caps_CapSet ) ^ hi.tpe.derivesFrom(defn.Caps_CapSet )) then
3061
+ report.error(em " Illegal type bounds: >: $lo <: $hi. Capture-set bounds cannot be mixed with type bounds of other kinds " , tdef.srcPos)
3062
+ if isCap && ! (lo.tpe.derivesFrom(defn.Caps_CapSet ) && hi.tpe.derivesFrom(defn.Caps_CapSet )) then
3063
+ report.error(em " Illegal type bounds: >: $lo <: $hi. $name^ can only have capture sets as bounds " , tdef.srcPos)
3064
+ case _ =>
3058
3065
assignType(cpy.TypeDef (tdef)(name, rhs1), sym)
3059
3066
}
3060
3067
Original file line number Diff line number Diff line change @@ -24,4 +24,8 @@ def test =
24
24
type M >: {x, y, O .z} <: {C }
25
25
type N >: {x} <: {x}
26
26
type O >: {O .z} <: {O .z}
27
- type P >: {B ,D } // error
27
+ type P >: {B ,D } // error
28
+ type Q >: {E } <: Int // error
29
+ type R ^ >: {E } <: Int // error
30
+ type S ^ >: Nothing <: Int // error
31
+ type T >: Nothing <: Int
You can’t perform that action at this time.
0 commit comments