-
Notifications
You must be signed in to change notification settings - Fork 29
SIP-77 - End markers for method blocks and anonymous classes #116
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
base: main
Are you sure you want to change the base?
Conversation
…ous classes to enhance readability and tooling support in Scala 3's braceless syntax.
|
||
- Binary and TASTy: No impact. End markers are purely syntactic sugar for braceless blocks and do not affect emitted bytecode or TASTy semantics. | ||
- Source: Largely backward compatible. The only change is accepting additional `end <id>` and `end new` tokens where previously only a dedentation closed the block. Name-checked markers that do not match will report errors as they do today for definition end markers. | ||
- Tooling: Formatters and IDEs may optionally insert or display these markers; existing code without markers remains valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of examples:
- Metals (via SemanticDB) - references to method symbol to include the new end marker
- Presentation Compiler? if that also reports symbol occurrences in source files
end apply | ||
``` | ||
|
||
- **Implicit `apply` calls**: Use the name of the object/class that owns the `apply` method when it's called implicitly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- **Implicit `apply` calls**: Use the name of the object/class that owns the `apply` method when it's called implicitly. | |
- **Implicit `apply` calls**: Use the name of the object/class instance that owns the `apply` method when it's called implicitly. |
I believe this was intended for cases like
class Foo:
def apply(block: => Unit): Unit = ()
val foo = new Foo
foo:
// do something
end foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll add this example
What about curried methods as they were not mentioned explicitly here? E.g. should this work? def foo(bar: String)(baz: String) = ???
foo("abc"):
"xyz"
end foo And similarly class CurriedFoo(bar: String):
def apply(baz: String) = ???
def foo(bar: String) = CurriedFoo(bar)
foo("abc"):
"xyz"
end foo |
Yes. Nothing explicitly is speced to prevent such application. |
No description provided.