Skip to content

Commit 34d8cc7

Browse files
committed
fix: annotations following type arguments
1 parent 42b4b74 commit 34d8cc7

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

grammar.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,14 @@ module.exports = grammar({
383383

384384
_unqualified_object_creation_expression: $ => prec.right(seq(
385385
'new',
386-
repeat($._annotation),
387-
field('type_arguments', optional($.type_arguments)),
386+
choice(
387+
seq(
388+
repeat($._annotation),
389+
field('type_arguments', $.type_arguments),
390+
repeat($._annotation),
391+
),
392+
repeat($._annotation),
393+
),
388394
field('type', $._simple_type),
389395
field('arguments', $.argument_list),
390396
optional($.class_body)

test/corpus/declarations.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,3 +1158,41 @@ void main() {
11581158
(identifier)
11591159
(formal_parameters)
11601160
(block)))
1161+
1162+
================================================================================
1163+
Annotation following type arguments
1164+
================================================================================
1165+
1166+
public class A {
1167+
public B() {
1168+
return new <@BG Inner> @BH Inner<@BI Inner>(null);
1169+
}
1170+
}
1171+
1172+
---
1173+
1174+
(program
1175+
(class_declaration
1176+
(modifiers)
1177+
(identifier)
1178+
(class_body
1179+
(constructor_declaration
1180+
(modifiers)
1181+
(identifier)
1182+
(formal_parameters)
1183+
(constructor_body
1184+
(return_statement
1185+
(object_creation_expression
1186+
(type_arguments
1187+
(annotated_type
1188+
(marker_annotation (identifier))
1189+
(type_identifier)))
1190+
(marker_annotation (identifier))
1191+
(generic_type
1192+
(type_identifier)
1193+
(type_arguments
1194+
(annotated_type
1195+
(marker_annotation (identifier))
1196+
(type_identifier))))
1197+
(argument_list
1198+
(null_literal)))))))))

0 commit comments

Comments
 (0)