-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
"is not a class type" error for given for intersection type #14175
Comments
Or, say, "Did you mean...?" and tell us what to write. One imagines a session like the following. As a footnote, error recovery on missing
|
So It's possible to do this given Foo with Bar with
def foo = 1
def bar = 2 So I am not sure what is the problem with |
Probably because you have to construct an instance.
That reminds me, I don't remember where I noticed |
Yes, but given Foo with Bar with
def foo = 1
def bar = 2
def fooBar(using fb: Foo & Bar) = fb.foo + fb.bar
println(fooBar) // 3 |
I meant to say that I forgot to add that comma is not a synonym for
While browsing the repo, I saw an old comment about disallowing |
The difference here is that intersection types can only be the types of return values, or parameters - a |
We sould probably add a |
This issue was picked for the Issue Spree No. 42 of February 6th, 2024. @SethTisue, @spavikevik, @iusildra, @aherlihy will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here. |
"Class type" is spec language that is not familiar to most Scala programmers. So we must either avoid it, or explain it. |
We have been discussing whether it's enough to change and/or add an "-explain" text to the general error message, or whether it's worth trying to make it specific to the It would be nice to avoid the term "class type", but we can't think of a concise alternative, so I guess we'll just add an "explain" text. We weren't sure initially how many other situations this error might come up in. It appears to us that the three main non-class types are intersection types, union types, and refinement types. (In Scala 2, only two error messages refer to "class type", and both appear intended to only exclude refinement types.) |
Compiler version
3.1.0
Minimized example
Output
compilation error
Expectation
I think something like
would be clearer
The text was updated successfully, but these errors were encountered: