-
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
Trait parameters are not abstract when Scala.js inspects them #12621
Comments
It's not the same in terms of compilation if they are moved to the body, though, is it? I'm not sure it would make sense from the perspective of semantics of JS types. JS traits are supposed to be pure interfaces without any implementation. |
Does it introduce a regression compared to Scala 2 Scala.js? @sjrd does your comment mean we can close this? |
Scala 2 doesn't have trait parameters, so definitely not a regression. Reporting an error is the correct thing to do. That said, the error message could be improved, saying something like "JS traits cannot have parameters" or something like that. |
if I compile this similar example object A {
trait Bag extends Any {
val str: String
}
trait TraitWithParam(val bag: Bag) extends Any
trait StdTrait extends Any {
val bag: Bag
}
val b: Bag = new { val str = "hello" }
class Foo extends TraitWithParam(b)
class Bar extends StdTrait {
val bag = b
}
} then both |
conceptually, parameters are concrete members so they should be disallowed, but we can special case the error message here |
Compiler version
3.0.0
Minimized code
Output
Expectation
no error, like if
val bag: Bag
is moved from trait params to the bodyThe text was updated successfully, but these errors were encountered: