[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:
Suyash Srijan
2020-03-31 23:16:08 +01:00
committed by GitHub
parent efa1a01a5a
commit 95f0651cbb
8 changed files with 194 additions and 2 deletions

View File

@@ -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 "