Skip to content

Commit

Permalink
Merge pull request #375 from susliko/abstract-extensions
Browse files Browse the repository at this point in the history
Allow $.function_declaration as extension body
  • Loading branch information
susliko authored Feb 11, 2024
2 parents 45b5ba0 + f8a4c13 commit 310f872
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion corpus/definitions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,9 @@ object A:

extension [A1](d: D) def foo = "foo"

trait B:
extension (x: Int) def bar: String

--------------------------------------------------------------------------------

(compilation_unit
Expand All @@ -1211,7 +1214,18 @@ object A:
(type_identifier)))
(function_definition
(identifier)
(string))))))
(string)))))
(trait_definition
(identifier)
(template_body
(extension_definition
(parameters
(parameter
(identifier)
(type_identifier)))
(function_declaration
(identifier)
(type_identifier))))))

================================================================================
Given instance definitions (Scala 3 syntax)
Expand Down
6 changes: 5 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,11 @@ module.exports = grammar({
field("parameters", repeat($.parameters)),
field(
"body",
choice($._extension_template_body, $.function_definition),
choice(
$._extension_template_body,
$.function_definition,
$.function_declaration,
),
),
),
),
Expand Down

0 comments on commit 310f872

Please sign in to comment.