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

NodeBuffer append is this.type #744

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Nov 25, 2024

Fixes #650

The signature should be like https://github.com/scala/scala/blob/v2.13.15/src/library/scala/collection/mutable/StringBuilder.scala#L142 so that linting knows it does not return a new value.

The generated code has the form

    private[this] val xml: scala.xml.Elem = new scala.xml.Elem(null, "xml", scala.xml.Null, scala.xml.TopScope, false, ({
      val $buf: scala.xml.NodeBuffer = new scala.xml.NodeBuffer();
      $buf.&+(new scala.xml.Elem(null, "elem", scala.xml.Null, scala.xml.TopScope, false));
      $buf
    }: _*));

@dubinsky
Copy link
Contributor

I do not understand why this change does not trigger the compatibility checker like other attempts to make the types more precise do, but I am all for this change!
Let's just wait a couple of days before merging it to give the people an opportunity to speak up.

@SethTisue
Copy link
Member

SethTisue commented Nov 25, 2024

MiMa analyzes bytecode. (There are a few situations in which it also consults the Scala signature, but that's not in play here.) this.type erases to the same thing as the old type, so MiMa (rightly) doesn't see anything to object to.

@som-snytt
Copy link
Contributor Author

I sympathize with the preceding question and answer. Compiler fictions FTW!

@dubinsky dubinsky merged commit 9a80bd3 into scala:main Nov 27, 2024
30 checks passed
@som-snytt som-snytt deleted the issue/12658-nodebuffer-append branch November 27, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unused value warnings for XML literals starting with Scala 2.13.9
3 participants