Skip to content

Add sealed option to mayHaveCommonChild #17194

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,7 @@ object SymDenotations {
* @return The result may contain false positives, but never false negatives.
*/
final def mayHaveCommonChild(that: ClassSymbol)(using Context): Boolean =
!this.is(Final) && !that.is(Final) && (this.is(Trait) || that.is(Trait)) ||
!this.isOneOf(FinalOrSealed) && !that.isOneOf(FinalOrSealed) && (this.is(Trait) || that.is(Trait)) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not valid, because the following hierarchy is allowed:

sealed trait A
sealed trait B
class C extends A with B

this.derivesFrom(that) || that.derivesFrom(this.symbol)

final override def typeParamCreationFlags: FlagSet = ClassTypeParamCreationFlags
Expand Down