@@ -141,7 +141,7 @@ type val var while with yield
141141### Soft keywords
142142
143143```
144- as derives end erased extension infix inline opaque open throws tracked transparent using | * + -
144+ as cap derives end erased extension infix inline mut opaque open throws tracked transparent using | * + -
145145```
146146
147147See the [ separate section on soft keywords] ( ../reference/soft-modifier.md ) for additional
@@ -182,15 +182,19 @@ Type ::= FunType
182182 | MatchType
183183 | InfixType
184184FunType ::= FunTypeArgs (‘=>’ | ‘?=>’) Type Function(ts, t) | FunctionWithMods(ts, t, mods, erasedParams)
185- | TypTypeParamClause '=>' Type PolyFunction(ps, t)
185+ | FunTypeArgs (‘->’ | ‘?->’) [CaptureSet] Type -- under pureFunctions and captureChecking
186+ | TypTypeParamClause ‘=>’ Type PolyFunction(ps, t)
187+ | TypTypeParamClause ‘->’ [CaptureSet] Type -- under pureFunctions and captureChecking
186188FunTypeArgs ::= InfixType
187189 | ‘(’ [ FunArgTypes ] ‘)’
188190 | FunParamClause
189191FunParamClause ::= ‘(’ TypedFunParam {‘,’ TypedFunParam } ‘)’
190192TypedFunParam ::= [`erased`] id ‘:’ Type
191193MatchType ::= InfixType `match` <<< TypeCaseClauses >>>
192194InfixType ::= RefinedType {id [nl] RefinedType} InfixOp(t1, op, t2)
195+ | RefinedType ‘^’ -- under captureChecking
193196RefinedType ::= AnnotType {[nl] Refinement} RefinedTypeTree(t, ds)
197+ | AnnotType {[nl] Refinement} [‘^’ CaptureSet] -- under captureChecking
194198AnnotType ::= SimpleType {Annotation} Annotated(t, annot)
195199AnnotType1 ::= SimpleType1 {Annotation} Annotated(t, annot)
196200
@@ -210,16 +214,18 @@ Singleton ::= SimpleRef
210214 | Singleton ‘.’ id
211215FunArgType ::= Type
212216 | ‘=>’ Type PrefixOp(=>, t)
217+ | ‘->’ [CaptureSet] Type -- under captureChecking
213218FunArgTypes ::= FunArgType { ‘,’ FunArgType }
214219ParamType ::= [‘=>’] ParamValueType
220+ | ‘->’ [CaptureSet] ParamValueType -- under captureChecking
215221ParamValueType ::= Type [‘*’] PostfixOp(t, "*")
216222 | IntoType
217223 | ‘(’ IntoType ‘)’ ‘*’ PostfixOp(t, "*")
218224IntoType ::= [‘into’] IntoTargetType Into(t)
219225 | ‘(’ IntoType ‘)’
220226IntoTargetType ::= Type
221227 | FunTypeArgs (‘=>’ | ‘?=>’) IntoType
222- TypeArgs ::= ‘[’ Types ‘]’ ts
228+ TypeArgs ::= ‘[’ TypeArg {‘,’ TypeArg} ‘]’ ts
223229Refinement ::= :<<< [RefineDcl] {semi [RefineDcl]} >>> ds
224230TypeBounds ::= [‘>:’ Type] [‘<:’ Type] TypeBoundsTree(lo, hi)
225231TypeAndCtxBounds ::= TypeBounds [‘:’ ContextBounds] ContextBounds(typeBounds, tps)
@@ -228,8 +234,15 @@ ContextBounds ::= ContextBound
228234 | '{' ContextBound {',' ContextBound} '}'
229235ContextBound ::= Type ['as' id]
230236Types ::= Type {‘,’ Type}
237+ TypeArg ::= Type
238+ | CaptureSet -- under captureChecking
231239NamesAndTypes ::= NameAndType {‘,’ NameAndType}
232240NameAndType ::= id ':' Type
241+ CaptureSet ::= ‘{’ CaptureRef {‘,’ CaptureRef} ‘}’ -- under captureChecking
242+ CaptureRef ::= { SimpleRef ‘.’ } SimpleRef [‘*’] [‘.’ ‘rd’] -- under captureChecking
243+ | [ { SimpleRef ‘.’ } SimpleRef ‘.’ ] id -- under captureChecking
244+ CaptureSetBounds ::= [‘>:’ CaptureSet ] [‘<:’ CaptureSet ] -- under captureChecking
245+ CaptureSetAndCtxBounds ::= CaptureSetBounds [‘:’ ContextBounds] -- under captureChecking
233246```
234247
235248### Expressions
@@ -365,16 +378,20 @@ ArgumentPatterns ::= ‘(’ [Patterns] ‘)’
365378ClsTypeParamClause::= ‘[’ ClsTypeParam {‘,’ ClsTypeParam} ‘]’
366379ClsTypeParam ::= {Annotation} [‘+’ | ‘-’] TypeDef(Modifiers, name, tparams, bounds)
367380 id [HkTypeParamClause] TypeAndCtxBounds Bound(below, above, context)
381+ | {Annotation} ‘cap’ id CaptureSetAndCtxBounds -- under captureChecking
368382
369383DefTypeParamClause::= [nl] ‘[’ DefTypeParam {‘,’ DefTypeParam} ‘]’
370384DefTypeParam ::= {Annotation} id [HkTypeParamClause] TypeAndCtxBounds
385+ | {Annotation} ‘cap’ id CaptureSetAndCtxBounds -- under captureChecking
371386
372387TypTypeParamClause::= ‘[’ TypTypeParam {‘,’ TypTypeParam} ‘]’
373388TypTypeParam ::= {Annotation} (id | ‘_’) [HkTypeParamClause] TypeBounds
389+ | {Annotation} ‘cap’ id CaptureSetAndCtxBounds -- under captureChecking
374390
375391HkTypeParamClause ::= ‘[’ HkTypeParam {‘,’ HkTypeParam} ‘]’
376392HkTypeParam ::= {Annotation} [‘+’ | ‘-’] (id | ‘_’) [HkTypeParamClause]
377393 TypeBounds
394+ | {Annotation} ‘cap’ id CaptureSetAndCtxBounds -- under captureChecking
378395
379396ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’]
380397ClsParamClause ::= [nl] ‘(’ ClsParams ‘)’
@@ -419,6 +436,8 @@ LocalModifier ::= ‘abstract’
419436 | ‘infix’
420437 | ‘erased’
421438 | ‘tracked’
439+ | ‘mut’ -- under captureChecking
440+ | ‘cap’ -- under captureChecking
422441
423442AccessModifier ::= (‘private’ | ‘protected’) [AccessQualifier]
424443AccessQualifier ::= ‘[’ id ‘]’
@@ -448,13 +467,15 @@ RefineDcl ::= ‘val’ ValDcl
448467 | ‘var’ ValDcl
449468 | ‘def’ DefDcl
450469 | ‘type’ {nl} TypeDef
470+ | ‘cap’ ‘type’ {nl} CapDef -- under captureChecking
451471ValDcl ::= ids ‘:’ Type
452472DefDcl ::= DefSig ‘:’ Type
453473
454474Def ::= ‘val’ PatDef
455475 | ‘var’ PatDef
456476 | ‘def’ DefDef
457477 | ‘type’ {nl} TypeDef
478+ | ‘cap’ ‘type’ {nl} CapDef -- under captureChecking
458479 | TmplDef
459480PatDef ::= ids [‘:’ Type] [‘=’ Expr]
460481 | Pattern2 [‘:’ Type] [‘=’ Expr] PatDef(_, pats, tpe?, expr)
@@ -463,6 +484,7 @@ DefDef ::= DefSig [‘:’ Type] [‘=’ Expr]
463484DefSig ::= id [DefParamClauses] [DefImplicitClause]
464485TypeDef ::= id [HkTypeParamClause] {FunParamClause} TypeAndCtxBounds TypeDefTree(_, name, tparams, bound
465486 [‘=’ Type]
487+ CapDef ::= id CaptureSetAndCtxBounds [‘=’ CaptureSet] -- under captureChecking
466488
467489TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef
468490 | [‘case’] ‘object’ ObjectDef
0 commit comments