swiftlang/swift

Bad diagnostic when inheriting from class in extension

オープン

#64,903 opened on 2023/04/04

 (21 件のコメント) (0 件のリアクション) (1 人の担当者)Swift (10,719 件のフォーク)batch import
bugcompilerdiagnostics qualityextensiongood first issueinheritanceswift 6.0type checker

Repository metrics

Stars
 (69,989 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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.

コントリビューターガイド