-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add explanation to checkCaseClassInheritanceInvariant error msg (#20141)
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]>
- Loading branch information
1 parent
926e6a3
commit ed9fecc
Showing
3 changed files
with
33 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- Error: tests/neg/i18552.scala:9:6 ----------------------------------------------------------------------------------- | ||
9 |class MB(id:Int) extends MA(id) with M[B] // error | ||
| ^ | ||
| illegal inheritance: class MB inherits conflicting instances of base trait M. | ||
| | ||
| Direct basetype: M[B] | ||
| Basetype via case class MA: M[A] | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| Refining a basetype of a case class is not allowed. | ||
| This is a limitation that enables better GADT constraints in case class patterns | ||
--------------------------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//> using options -explain | ||
|
||
trait A | ||
trait B extends A | ||
|
||
trait M[+T] | ||
|
||
case class MA(id:Int) extends M[A] | ||
class MB(id:Int) extends MA(id) with M[B] // error |