-
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
Add explanation to checkCaseClassInheritanceInvariant error msg #20141
Conversation
Closes scala#18552 which was actually not an error, see: https://github.com/scala/scala3/blob/73882c5b62b8cd96031ad975f7677949433a9f21/compiler/src/dotty/tools/dotc/typer/RefChecks.scala#L889-L893 Co-authored-by: Anna Herlihy <[email protected]> Co-authored-by: Natsu Kagami <[email protected]>
9a04756
to
fd84324
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay to me!
Two minor questions:
- Is the word "conflicting" really appropriate here? If it is easy to change, maybe I'd write something like "class MB cannot inherit from two instances of base trait M".
- Is it clear that "enabling better GADT constraints" explains why it is implemented that way? Maybe split in a second sentence "This is an implementation limitation that enables better GADT constraints in case class patterns".
@SimonGuilloud what do you think? Would this message have helped? |
Technically speaking, it can inherit from two instances trait M[+T]
case class MAny(id:Int) extends M[Int]
class MInt(id:Int) extends MAny(id) with M[Any]
// Ok: they do not conflict since M[Int] <: M[Any]
trait M[+T]
case class Mcc(id:Int)
class MAny(id:Int) extends Mcc(id) with M[Any]
class MInt(id:Int) extends MAny(id) with M[Int]
// Ok: the "conflicting" instances are only below the case class
trait M[+T]
case class MAny(id:Int) extends M[Any]
class MInt(id:Int) extends MAny(id) with M[Int]
// Error because M[Int] refines M[Any] which is a base type of an intermediate case class
I agree that's better 👍 |
I think it is certainly better ("This error is blatantly wrong" => "I don't understand the message but alright"). |
Closes #18552 which was actually not an error, see: https://github.com/scala/scala3/blob/73882c5b62b8cd96031ad975f7677949433a9f21/compiler/src/dotty/tools/dotc/typer/RefChecks.scala#L889-L893 --------- Co-authored-by: Anna Herlihy <[email protected]> Co-authored-by: Natsu Kagami <[email protected]> [Cherry-picked ed9fecc][modified]
Closes #18552 which was actually not an error, see:
scala3/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Lines 889 to 893 in 73882c5
Co-authored-by: Anna Herlihy [email protected]
Co-authored-by: Natsu Kagami [email protected]