mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Diagnostics] Emit a warning when an immutable decodable property has an initial value (#30218)
* [Diagnostics] Emit a warning when an immutable decodable property has an initial value * [Sema] Use Decl::diagnose instead of Diags.diagnose * [AST] Remove property name from 'decodable_property_will_not_be_decoded' diagnostic * [Test] Update tests * [Test] Update existing codable tests
This commit is contained in:
@@ -2758,6 +2758,19 @@ NOTE(decodable_suggest_overriding_init_here,none,
|
||||
NOTE(codable_suggest_overriding_init_here,none,
|
||||
"did you mean to override 'init(from:)' and 'encode(to:)'?", ())
|
||||
|
||||
WARNING(decodable_property_will_not_be_decoded, none,
|
||||
"immutable property will not be decoded because it is declared with "
|
||||
"an initial value which cannot be overwritten", ())
|
||||
NOTE(decodable_property_init_or_codingkeys_implicit, none,
|
||||
"set the initial value via the initializer or explicitly define a "
|
||||
"CodingKeys enum %select{including|without}0 a %1 case to silence "
|
||||
"this warning", (unsigned, DeclName))
|
||||
NOTE(decodable_property_init_or_codingkeys_explicit, none,
|
||||
"set the initial value via the initializer or remove the %0 case from "
|
||||
"the CodingKeys enum to silence this warning", (DeclName))
|
||||
NOTE(decodable_make_property_mutable, none,
|
||||
"make the property mutable instead", ())
|
||||
|
||||
NOTE(missing_member_type_conformance_prevents_synthesis, none,
|
||||
"%select{associated value|stored property}0 type %1 does not conform to "
|
||||
"protocol %2, preventing synthesized conformance "
|
||||
|
||||
Reference in New Issue
Block a user