Skip to content

Not include abstract classes in type switch #60027

@BbIXOD

Description

@BbIXOD

To reproduce

  1. create base abstract class
  2. create one or more derivatives
  3. switch variable of type Base by type in case where you need to implement complete match

Example

abstract class Base {}

class Derived extends Base {}

class AnotherDerived extends Base {}

Base? foo(Base b) {
  return switch (b) {
    Derived _ => null,
    AnotherDerived _ => null,
    // without this we have trouble: Base _ => null,
  };
}

Expected behavior

Linter does not complain, everything is fine

Actual behavior

Linter complains that match is not complete

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions