Skip to content

Allow .asInstanceOf[Matchable] as this is erased to Object #1763

Open
@seigert

Description

In Scala 3 declaration of equals is def equals(obj: Any): Boolean = ???. This means that any attempt to match on a class instance in equals body is met with

[error]    |                   pattern selector should be an instance of Matchable,,
[error]    |                   but it has unmatchable type Any instead

Official documentation suggest to fix this with obj.asInstanceOf[Matchable] as this is guaranteed to succeed.

But this triggers DisableSyntax.noAsInstanceOf rule for almost every custom .equals.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions