Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow return types on new lines in definitions #333

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion corpus/definitions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,9 @@ class A {

def n(using a: A)
(using B <:< B, C =:= C) = ()

def o()
: Int = 42
}

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -1119,7 +1122,12 @@ class A {
(type_identifier)
(operator_identifier)
(type_identifier)))
(unit)))))
(unit))
(function_definition
(identifier)
(parameters)
(type_identifier)
(integer_literal)))))

================================================================================
Function definitions (Scala 3 syntax)
Expand Down Expand Up @@ -1208,6 +1216,9 @@ object A:
private given listFoo[A1](using ev: CanFoo[A1]): CanFoo[List[A1]] with
def foo(xs: List[A1]): Int = 0

given foo(using ev: Foo)
: Foo = ev

given [T: Ordering]: Ordering[List[T]] with
def x = ()

Expand Down Expand Up @@ -1287,6 +1298,14 @@ object A:
(type_identifier)))))
(type_identifier)
(integer_literal))))
(given_definition
(identifier)
(parameters
(parameter
(identifier)
(type_identifier)))
(type_identifier)
(identifier))
(given_definition
(identifier
(MISSING _alpha_identifier))
Expand Down
1 change: 1 addition & 0 deletions grammar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PREC = {

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-20.04)

ok, scala_scala/src/library/: 100.00%, expected at least 100%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-20.04)

ok, scala_scala/src/compiler/: 96.31%, expected at least 96%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-20.04)

ok, dotty/compiler/: 84.28%, expected at least 84%
comment: 1,
using_directive: 2,
control: 1,
Expand Down Expand Up @@ -550,6 +550,7 @@
"parameters",
repeat(seq(optional($._automatic_semicolon), $.parameters)),
),
optional($._automatic_semicolon),
),
),

Expand Down Expand Up @@ -854,7 +855,7 @@
),
),

tuple_type: $ => seq("(", trailingCommaSep1($._type), ")"),

Check notice on line 858 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-20.04)

ok, complexity of the most complex definition tuple_type: 1269, lower than the allowed ceiling 1300

singleton_type: $ =>
prec.left(
Expand Down