Skip to content

Commit 66d3e02

Browse files
authored
Merge pull request #650 from tree-sitter/capture-set-reach
fix: take the reach capability in a capture set
2 parents 6e9e496 + 6b40499 commit 66d3e02

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

grammar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,10 @@ module.exports = grammar({
16851685
capture_ref: $ =>
16861686
seq(
16871687
choice($._identifier, $.stable_identifier, "cap"),
1688+
// The reach capability `xs*`, which stands for what the elements of
1689+
// `xs` capture. It comes before the narrowing suffixes. Right before
1690+
// the closing brace the star arrives as the external token instead.
1691+
optional(choice($._asterisk, $._postfix_star)),
16881692
repeat(
16891693
seq(
16901694
".",

test/corpus/types.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,55 @@ def h(x: ->{any} I) = x
546546
(type_identifier))))
547547
(identifier)))
548548

549+
================================================================================
550+
Reach capability in a capture set (Scala 3 capture checking)
551+
================================================================================
552+
553+
def add(fut: Future[T]^{futs*}) = ???
554+
555+
type F = () ->{c.procs*} Unit
556+
557+
type G = List[() ->{xs*} Unit]
558+
559+
--------------------------------------------------------------------------------
560+
561+
(compilation_unit
562+
(function_definition
563+
(identifier)
564+
(parameters
565+
(parameter
566+
(identifier)
567+
(capturing_type
568+
(generic_type
569+
(type_identifier)
570+
(type_arguments
571+
(type_identifier)))
572+
(capture_set
573+
(capture_ref
574+
(identifier))))))
575+
(operator_identifier))
576+
(type_definition
577+
(type_identifier)
578+
(function_type
579+
(parameter_types)
580+
(capture_set
581+
(capture_ref
582+
(stable_identifier
583+
(identifier)
584+
(identifier))))
585+
(type_identifier)))
586+
(type_definition
587+
(type_identifier)
588+
(generic_type
589+
(type_identifier)
590+
(type_arguments
591+
(function_type
592+
(parameter_types)
593+
(capture_set
594+
(capture_ref
595+
(identifier)))
596+
(type_identifier))))))
597+
549598
================================================================================
550599
Compound types
551600
================================================================================

0 commit comments

Comments
 (0)