-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Creator application is lost on type alias (e.g. on AnyRef
)
#10862
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
Comments
That works as expected since the rules have changed. |
at #10784 (comment) you write:
What about the |
It means every time we want to relocate a type, we have to define its constructor proxy by hand. This is eventually not a problem for me. @SethTisue you can define a
|
Seeing as you get a pseudo You can't scala> object foo { class A(n: Int) }; type A = foo.A; val A = foo.A
1 |object foo { class A(n: Int) }; type A = foo.A; val A = foo.A
| ^^^^^
| constructor proxy object A cannot be used as a value
scala> object foo { class A(n: Int); object A }; type A = foo.A; val A = foo.A
// defined object foo
// defined alias type A = foo.A
val A: foo.A.type = foo$A$@6cee903a
scala> A(1)
val res3: foo.A = foo$A@e36bc01 Are users intended to write their own alias-site objects like rjolly's |
The cool thing is that you don't actually have to implement object foo {
class A(n: Int)
object A
}
type A = foo.A
val A = foo.A
println(A(1)) // ok Edit : for comparison this works, with or without the object foo {
case class A(n: Int)
}
type A = foo.A
val A = foo.A
println(A(1)) // ok Edit2 : so maybe what we should do is take for granted that object foo {
class A(n: Int)
object A
}
import foo.A
println(A(1)) // ok |
Yes, as @rjolly writes, we already require About |
I don't have to have an |
when I need a lock to synchronize on, I do:
|
This came up on Discord today, except instead of |
Might Would the situation be any different if the |
AnyRef
)
Minimized code and output
Expectation : should work as with
new
The text was updated successfully, but these errors were encountered: