Skip to content

Commit db16e80

Browse files
committed
support variance annotation
1 parent d3d54cb commit db16e80

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

grammar.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,12 @@ module.exports = grammar({
257257

258258
type_parameters: $ => seq(
259259
'<',
260-
commaSep1t($.type_identifier),
260+
commaSep1t(
261+
seq(
262+
optional(choice('+', '-')),
263+
$.type_identifier
264+
)
265+
),
261266
'>',
262267
),
263268

test/corpus/type_declarations.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,20 @@ type test = (. ~attr: string) => unit
417417
(type_annotation
418418
(type_identifier)))))
419419
(unit_type))))
420+
421+
===========================================
422+
Variance annotations
423+
===========================================
424+
425+
type t<+'a>
426+
type t<-'a>
427+
428+
---
429+
430+
(source_file
431+
(type_declaration
432+
(type_identifier)
433+
(type_parameters (type_identifier)))
434+
(type_declaration
435+
(type_identifier)
436+
(type_parameters (type_identifier))))

0 commit comments

Comments
 (0)