Skip to content

Export of class fails with "constructor proxy ... cannot be used as a value" #11128

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
ellbur opened this issue Jan 15, 2021 · 4 comments · Fixed by #11151
Closed

Export of class fails with "constructor proxy ... cannot be used as a value" #11128

ellbur opened this issue Jan 15, 2021 · 4 comments · Fixed by #11151
Assignees
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala itype:bug
Milestone

Comments

@ellbur
Copy link

ellbur commented Jan 15, 2021

With Scala 3.0.0-M3

Minimized code

A minimal example consisting of the two source files below is on GitHub.

package.scala

package object foo {
  export foo.bar.Bar
}

Bar.scala

package foo.bar

class Bar

Output

$ sbt compile
[error] 3 |  export foo.bar.Bar
[error]   |         ^^^^^^^
[error]   |         constructor proxy object Bar cannot be used as a value

Expectation

Code should compile without errors.

@ellbur
Copy link
Author

ellbur commented Jan 15, 2021

Tested that error is the same with 3536773 (current master).

@ellbur
Copy link
Author

ellbur commented Jan 15, 2021

As a workaround, adding a dummy object prevents Scala from thinking you are referring to the constructor proxy:

Bar.scala

class Bar

object Bar

@bishabosha bishabosha self-assigned this Jan 15, 2021
@bishabosha
Copy link
Member

minimised to

package foo

object Wrap {
  export foo.Bar
}

class Bar

@bishabosha bishabosha added the area:desugar Desugaring happens after parsing but before typing, see desugar.scala label Jan 15, 2021
@odersky
Copy link
Contributor

odersky commented Jan 18, 2021

I believe we just need another condition on line 998 of Namer.scala

          else if (sym.isConstructor || sym.is(ModuleClass) || sym.is(Bridge)) SKIP

should be ... || sym.is(ConstructorProxy).

bishabosha added a commit to dotty-staging/dotty that referenced this issue Jan 18, 2021
bishabosha added a commit to dotty-staging/dotty that referenced this issue Jan 18, 2021
odersky added a commit that referenced this issue Jan 18, 2021
fix #11128: skip ctor proxy in named export
unkarjedy added a commit to unkarjedy/dotty that referenced this issue Aug 19, 2021
Currently, the docs say:
> A member is eligible if all of the following holds:
> ...
> it is not a constructor, nor the (synthetic) class part of an object,

However, constructor proxies are exported and they are synthetic

related: scala#11128
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants