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
Confusing first error message that overriding type members is possible #6001
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6001?orig=1 |
DaveScala (davescala) said: There seems to be one possibility when overriding concrete type members is allowed by the compiler and that is when the definition is exactly the same. |
DaveScala (davescala) said: |
@adriaanm said: |
@adriaanm said: |
@gkossakowski said: |
@retronym said: |
Fixes scala/bug#6001 This fixes the error message for overriding a concrete type alias. ### before ```scala override-concrete-type.scala:7: error: overriding type A1 in class Foo, which equals Something; type A1 has incompatible type class Bar extends Foo { override type A1 = Something with Serializable } ^ one error found ``` ### after ```scala override-concrete-type.scala:7: error: overriding type A1 in class Foo, which equals Something; overriding concrete type alias type A1 is not allowed except when equivalent class Bar extends Foo { override type A1 = Something with Serializable } ^ one error found ``` This error message was suggested in scala/bug#6001 (comment).
Fixes scala/bug#6001 This fixes the error message for overriding a concrete type alias. ### before ```scala override-concrete-type.scala:7: error: overriding type A1 in class Foo, which equals Something; type A1 has incompatible type class Bar extends Foo { override type A1 = Something with Serializable } ^ one error found ``` ### after ```scala override-concrete-type.scala:7: error: overriding type A1 in class Foo, which equals Something; overriding concrete type alias type A1 is not allowed except when equivalent class Bar extends Foo { override type A1 = Something with Serializable } ^ one error found ``` This error message was suggested in scala/bug#6001 (comment).
Fixes scala/bug#6001 This fixes the error message for overriding a concrete type alias. before ```scala override-concrete-type.scala:7: error: overriding type A1 in class Foo, which equals Something; type A1 has incompatible type class Bar extends Foo { override type A1 = Something with Serializable } ^ one error found ``` after ```scala override-concrete-type.scala:7: error: overriding type A1 in class Foo, which equals Something; overriding concrete type alias type A1 is not allowed except when equivalent class Bar extends Foo { override type A1 = Something with Serializable } ^ one error found ``` This error message was suggested in scala/bug#6001 (comment). Additionally, this improves "this can be resolved" note. ```scala t5358.scala:3: error: class C inherits conflicting members: method hi in trait A of type => String and method hi in trait B of type => String (note: this can be resolved by declaring an `override' in class C.) class C extends A with B ^ ```
scala/bug#6001. Fix error message for overriding type alias
When trying to override a concrete type member without a override keyword the compiler returns an error saying that the override keyword must be used.
But after applying the overriding keyword the compiler says that the type member is incompatible. It could already be said before.
Maybe also a more unambiguous message like "Overriding concrete type members is not allowed".
"type Hello has incompatible type" suggests too much that the error is in this case the relation between MyClass and MyClass with Serializable.
The text was updated successfully, but these errors were encountered: