swiftlang/swift

Bad diagnostic when inheriting from class in extension

Open

#64 903 ouverte le 4 avr. 2023

Voir sur GitHub
 (21 commentaires) (0 réactions) (1 assigné)Swift (10 719 forks)batch import
bugcompilerdiagnostics qualityextensiongood first issueinheritanceswift 6.0type checker

Métriques du dépôt

Stars
 (69 989 stars)
Métriques de merge PR
 (Merge moyen 8j 17h) (510 PRs mergées en 30 j)

Description

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 c1d5118c21d)

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

Guide contributeur