swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.25k stars 10.32k forks source link

[SR-13892] Improve diagnostics involving "covariant 'Self'" #56289

Open typesanitizer opened 3 years ago

typesanitizer commented 3 years ago
Previous ID SR-13892
Radar rdar://problem/71694596
Original Reporter @typesanitizer
Type Improvement
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | Improvement, DiagnosticsQoI, TypeChecker | |Assignee | None | |Priority | Medium | md5: 8c7922d3a5fa72593814951d5e61330a

Issue Description:

Confusion in forum post: https://forums.swift.org/t/why-error-covariant-self-type-cannot-be-referenced-from-a-stored-property-initializer/42235 involving the diagnostic

"covariant 'Self' type cannot be referenced from a stored property initializer"

It is not necessarily obvious to a developer what this means. We should do some combination of rewording the diagnostic, add an extra note explaining the issue, and maybe add a fix-it replacing 'Self' with the name of the class.

typesanitizer commented 3 years ago

@swift-ci create