Skip to content

Conversation

soronpo
Copy link
Contributor

@soronpo soronpo commented Aug 25, 2025

No description provided.

…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.
Copy link
Member

@bishabosha bishabosha Aug 26, 2025

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **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

Copy link
Contributor Author

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

@prolativ
Copy link
Contributor

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

@soronpo
Copy link
Contributor Author

soronpo commented Sep 25, 2025

E.g. should this work?

Yes. Nothing explicitly is speced to prevent such application.

@bracevac bracevac changed the title SIP-NN - End markers for method blocks and anonymous classes SIP-77 - End markers for method blocks and anonymous classes Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants