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

Unstable compiler output depending on order of package.scala and client code that uses type aliased defined therein #12092

Closed
retronym opened this issue Jul 22, 2020 · 2 comments · Fixed by scala/scala#9661
Assignees
Milestone

Comments

@retronym
Copy link
Member

Here's a variant in userland, where the package object does not participate in root imports.

  @Test def testPackageObjectUserLand(): Unit = {
    def code = List[SourceFile](
      source("package.scala", "package userland; object `package` { type Throwy = java.lang.Throwable }"),
      source("th.scala", "package userland; class th[T <: Throwy](cause: T = null)")
    )
    test(code :: Nil, permuter = _.reverse :: Nil)
  }

When th.scala appears before package.scala, naming the PackageDef in th.scala with:

    def enterPackage(tree: PackageDef) {
      val sym = createPackageSymbol(tree.pos, tree.pid)
      tree.symbol = sym
      newNamer(context.make(tree, sym.moduleClass, sym.info.decls)) enterSyms tree.stats
    }

... forces the info of the the package class symbol, including entering the members of the package.class. Again, we end up with two symbols representing the same entity which results in a different (albeit semantically equivalent) pickle. I'm pretty sure there is also a correctness bug here in that references to members of package.class that no longer in package.scala might not result in "no such symbol" errors.

Originally posted by @retronym in #12086 (comment)

@retronym retronym changed the title Here's a variant in userland, where the package object does not participate in root imports. Unstable compiler output depending on order of package.scala and client code that uses type aliased defined therein Jul 22, 2020
@SethTisue SethTisue added this to the Backlog milestone Oct 12, 2020
@SethTisue
Copy link
Member

SethTisue commented Oct 12, 2020

@retronym I've milestoned it Backlog, but you could re-milestone if you like

@retronym
Copy link
Member Author

Possibly fixed by this idea: scala/scala#9664

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants