Skip to content

Bad diagnostic when inheriting from class in extension #64903

@AnthonyLatsis

Description

@AnthonyLatsis

The following errors are misleading and could use a rewording as clear language rules, depending on the kinds of extended and inherited types.

protocol P {} struct S {} class C1 {} class C2 {} extension C2: S {} // error: inheritance from non-protocol type 'S' extension C2: C1 {} // error: inheritance from non-protocol type 'C1' extension C2: C1 & P {} // error: inheritance from class-constrained protocol composition type 'C1 & P'

Environment

  • Swift version 5.9-dev (LLVM 6a04c4848990c70, Swift c1d5118)

NB: How to improve on these is left as an exercise to whoever takes the issue.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationextensionFeature → declarations: `extension` declarationsgood first issueGood for newcomersinheritanceFeature → type declarations → class: Subclassing and inheritance of class membersswift 6.0type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions