Skip to content

no creator proxies for exported classes without a companion #11229

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

Closed
bishabosha opened this issue Jan 27, 2021 · 3 comments · Fixed by #12311
Closed

no creator proxies for exported classes without a companion #11229

bishabosha opened this issue Jan 27, 2021 · 3 comments · Fixed by #12311
Assignees
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Jan 27, 2021

Compiler version

3.0.0-RC1-bin-SNAPSHOT at e10cfa8

Minimized example

object Outer {

  object Wrap {
    export Outer.Bar
  }

  class Bar

  val wrapBar = Wrap.Bar()
}

Output

9 | val wrapBar = Wrap.Bar()
  |               ^^^^^^^^
  |               value Bar is not a member of object Outer.Wrap

Expectation

no compilation error. If I add a companion to Bar then there is no error.

This is against my expectation because usually classes have creator proxies synthesized if no companion is explicitly declared

@odersky
Copy link
Contributor

odersky commented Jan 27, 2021

Does it also happen if you do not do an export of an outer class? That one looks positively weird to me, and it might well mess with initialization order/

@bishabosha
Copy link
Member Author

bishabosha commented Jan 27, 2021

Does it also happen if you do not do an export of an outer class?

This has the same behaviour, (works if you add a companion to Inner.Bar)

object Outer {

  object Inner {
    class Bar
  }

  export Inner.Bar

  val bar = Bar() // error

}

@bishabosha bishabosha assigned bishabosha and odersky and unassigned bishabosha Mar 29, 2021
@odersky
Copy link
Contributor

odersky commented Apr 6, 2021

This arises since constructor proxies are only created for classes, and exports give type aliases, not classes. Maybe a better solution would be to find a way to allow constructor proxies also for type aliases.

odersky added a commit to dotty-staging/dotty that referenced this issue May 4, 2021
When creating an exported type alias of a class that has a constructor proxy companion,
export an alias for that companion with it. The alias is again a constructor proxy.

Fixes scala#11229
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
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.

3 participants