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

Static forwarder for local method is not consistently generated #18248

Open
raboof opened this issue Jul 19, 2023 · 2 comments
Open

Static forwarder for local method is not consistently generated #18248

raboof opened this issue Jul 19, 2023 · 2 comments
Labels
area:backend itype:bug stat:needs minimization Needs a self contained minimization

Comments

@raboof
Copy link
Contributor

raboof commented Jul 19, 2023

Compiler version

3.3.2-RC1-bin-20230718-da16f43-NIGHTLY

Minimized code

I have not minimized this yet, I will improve the issue later, but encountered it when building https://github.com/apache/incubator-pekko/blob/v1.0.1-RC1/actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/ExtensionsImpl.scala#L32-L138 with sbt:

private[pekko] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] with InternalRecipientRef[_] =>

  def loadExtensions(): Unit = {

    def loadExtensions(key: String, throwOnLoadFail: Boolean): Unit = {
        (...)
    }
    (...)

    loadExtensions("pekko.actor.typed.library-extensions", throwOnLoadFail = true)
    loadExtensions("pekko.actor.typed.extensions", throwOnLoadFail = false)
  }

  (...)
}

Output

The resulting ExtensionsImpl.class sometimes has a public static void loadExtensions$1$(org.apache.pekko.actor.typed.internal.ExtensionsImpl, java.lang.String, boolean);, and sometimes doesn't.

This method cannot be called from 'outside' so this forwarder likely isn't needed, but it would be good to either consistently generate it or consistently not generate it.

Expectation

Produce exactly the same class for the same source each time.

@raboof raboof added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 19, 2023
@jchyb jchyb added area:backend stat:needs minimization Needs a self contained minimization labels Jul 19, 2023
@dwijnand dwijnand removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jul 24, 2023
@raboof
Copy link
Contributor Author

raboof commented Jul 26, 2023

Unfortunately I haven't managed to create a minimal reproducer, however I can fairly reliably reproduce the problem building Pekko.

I'm noticing something strange in BCodeSkelBuilder.scala: it seems just when needsStaticImplMethod is being determined, concurrently dd.symbol.lastDenot changes from one that is 'public' with name loadExtensions to one that is private with name loadExtensions$1. Does that ring a bell to anyone?

(also: it's confusing that there are two methods named 'loadExtensions' here. the problem is with the 'inner' method and reproduces when the names are different as well)

raboof added a commit to raboof/pekko that referenced this issue Oct 14, 2023
pjfanning pushed a commit to apache/pekko that referenced this issue Oct 15, 2023
raboof added a commit to raboof/pekko that referenced this issue Oct 16, 2023
pjfanning pushed a commit to apache/pekko that referenced this issue Oct 16, 2023
@raboof
Copy link
Contributor Author

raboof commented May 30, 2024

Interestingly, it turns out the fact that both methods were named loadExtensions was irrelevant here: after changing the code to:

private[pekko] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] with InternalRecipientRef[_] =>

  def loadExtensions(): Unit = {

    def loadExtensionsFor(key: String, throwOnLoadFail: Boolean): Unit = {
        (...)
    }
    (...)

    loadExtensionsFor("pekko.actor.typed.library-extensions", throwOnLoadFail = true)
    loadExtensionsFor("pekko.actor.typed.extensions", throwOnLoadFail = false)
  }

  (...)
}

we encountered the problem again in our 1.1.0-M1 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:backend itype:bug stat:needs minimization Needs a self contained minimization
Projects
None yet
Development

No branches or pull requests

3 participants