Skip to content

Commit

Permalink
Merge pull request #92 from kawaemon/fix/generic-type-accepts-qualifi…
Browse files Browse the repository at this point in the history
…ed-type

Allow GenericType to accept QualifiedType
  • Loading branch information
aryx authored Oct 20, 2022
2 parents 1341814 + dea1c78 commit 05900fa
Show file tree
Hide file tree
Showing 6 changed files with 20,522 additions and 18,627 deletions.
13 changes: 13 additions & 0 deletions corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ func f2() (result int, err error) {}
func f(x ... int, y ... int)
func g1[T, U any, V interface{}, W Foo[Bar[T]]](a Foo[T]) {}
func g1[T, U any, V interface{}, W Foo[Bar[T]]](a Foo[T]) {}
func g2(a foo.bar[int]) {}
func f[A int|string, B ~int, C ~int|~string]()

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -353,6 +354,18 @@ func f[A int|string, B ~int, C ~int|~string]()
(type_arguments
(type_identifier)))))
(block))
(function_declaration
(identifier)
(parameter_list
(parameter_declaration
(identifier)
(generic_type
(qualified_type
(package_identifier)
(type_identifier))
(type_arguments
(type_identifier)))))
(block))
(function_declaration
(identifier)
(type_parameter_list
Expand Down
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ module.exports = grammar({
),

generic_type: $ => seq(
field('type', $._type_identifier),
field('type', choice($._type_identifier, $.qualified_type)),
field('type_arguments', $.type_arguments),
),

Expand Down
13 changes: 11 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,17 @@
"type": "FIELD",
"name": "type",
"content": {
"type": "SYMBOL",
"name": "_type_identifier"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_type_identifier"
},
{
"type": "SYMBOL",
"name": "qualified_type"
}
]
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,10 @@
"multiple": false,
"required": true,
"types": [
{
"type": "qualified_type",
"named": true
},
{
"type": "type_identifier",
"named": true
Expand Down
Loading

0 comments on commit 05900fa

Please sign in to comment.