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

("A" | "B") <:< Singleton ? #15052

Closed
armanbilge opened this issue Apr 27, 2022 · 1 comment
Closed

("A" | "B") <:< Singleton ? #15052

armanbilge opened this issue Apr 27, 2022 · 1 comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@armanbilge
Copy link
Contributor

Compiler version

3.1.2

Minimized code

Welcome to Scala 3.1.2 (11.0.13, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                 
scala> summon[("A" | "B") <:< Singleton]
val res0: ("A" | "B") =:= ("A" | "B") = generalized constraint
                                                                                                                                                                 
scala> summon[ValueOf["A" | "B"]]
-- Error: -------------------------------------------------------------------------------------------------------------------------------------------------------
1 |summon[ValueOf["A" | "B"]]
  |                          ^
  |                          No singleton value available for ("A" : String) | ("B" : String).
1 error found
                                                                                                                                                                 
scala> 

Expectation

Seems strange that there is an instance of ("A" | "B") <:< Singleton. I was mighty curious what ValueOf might return!

@armanbilge armanbilge added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 27, 2022
@smarter
Copy link
Member

smarter commented Apr 27, 2022

Seems strange that there is an instance of ("A" | "B") <:< Singleton

It's inevitable because "A" <: Singleton and "B" <: Singleton, this is a known design flaw of Singleton (which predates union types) and eventually we'll have to replace it with some other mechanism, see #4944.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

2 participants