File tree Expand file tree Collapse file tree 3 files changed +51
-4
lines changed Expand file tree Collapse file tree 3 files changed +51
-4
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,13 @@ module.exports = grammar({
321321 $ . unit_type ,
322322 $ . module_pack ,
323323 $ . unit ,
324+ $ . polymorphic_type ,
325+ ) ,
326+
327+ polymorphic_type : $ => seq (
328+ choice ( repeat1 ( $ . type_identifier ) , $ . abstract_type ) ,
329+ '.' ,
330+ $ . _inline_type
324331 ) ,
325332
326333 type_constraint : $ => seq (
@@ -817,7 +824,7 @@ module.exports = grammar({
817824 $ . _pattern ,
818825 $ . labeled_parameter ,
819826 $ . unit ,
820- $ . type_parameter ,
827+ $ . abstract_type
821828 ) ,
822829 ) ,
823830
@@ -829,7 +836,7 @@ module.exports = grammar({
829836 optional ( field ( 'default_value' , $ . _labeled_parameter_default_value ) ) ,
830837 ) ,
831838
832- type_parameter : $ => seq (
839+ abstract_type : $ => seq (
833840 'type' ,
834841 repeat1 ( $ . type_identifier ) ,
835842 ) ,
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ Type annotations
7979 body: (number))))
8080
8181===================================================
82- Type arguments
82+ Abstract type
8383===================================================
8484
8585let foo = (type a, x: 'a): a => x
@@ -91,7 +91,7 @@ let foo = (type a, x: 'a): a => x
9191 (value_identifier)
9292 (function
9393 (formal_parameters
94- (parameter (type_parameter (type_identifier)))
94+ (parameter (abstract_type (type_identifier)))
9595 (parameter
9696 (value_identifier)
9797 (type_annotation (type_identifier))))
Original file line number Diff line number Diff line change @@ -461,6 +461,46 @@ type test = (. ~attr: string) => unit
461461 (type_identifier)))))
462462 (unit_type))))
463463
464+ ===========================================
465+ Polymorphic type
466+ ===========================================
467+
468+ let id: 'a. 'a => 'a = x => x
469+
470+ let add: type a. (number<a>, number<a>) => a
471+
472+ ---
473+
474+ (source_file
475+ (let_binding
476+ (value_identifier)
477+ (type_annotation
478+ (polymorphic_type
479+ (type_identifier)
480+ (function_type
481+ (function_type_parameters (type_identifier))
482+ (type_identifier))))
483+ (function
484+ (value_identifier)
485+ (value_identifier)))
486+
487+ (let_binding
488+ (value_identifier)
489+ (type_annotation
490+ (polymorphic_type
491+ (abstract_type (type_identifier))
492+ (function_type
493+ (function_type_parameters
494+ (parameter
495+ (generic_type
496+ (type_identifier)
497+ (type_arguments (type_identifier))))
498+ (parameter
499+ (generic_type
500+ (type_identifier)
501+ (type_arguments
502+ (type_identifier))))) (type_identifier))))))
503+
464504===========================================
465505Variance annotations
466506===========================================
You can’t perform that action at this time.
0 commit comments