Skip to content

Commit f4006c3

Browse files
authored
Merge pull request swiftlang#31037 from HassanElDesouky/SR-12248
[TypeChecker] `<unknown>` diagnostic location regarding `Codable` derived conformances
2 parents 4e56349 + 44402d4 commit f4006c3

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
711711
current->diagnose(diag::invalid_redecl_init,
712712
current->getFullName(),
713713
otherInit->isMemberwiseInitializer());
714-
} else {
714+
} else if (!current->isImplicit() && !other->isImplicit()) {
715715
ctx.Diags.diagnoseWithNotes(
716716
current->diagnose(diag::invalid_redecl,
717717
current->getFullName()), [&]() {

test/Sema/enum_conformance_synthesis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func customHashable() {
6161
enum InvalidCustomHashable {
6262
case A, B
6363

64-
var hashValue: String { return "" } // expected-note {{previously declared here}}
64+
var hashValue: String { return "" }
6565
}
6666
func ==(x: InvalidCustomHashable, y: InvalidCustomHashable) -> String {
6767
return ""

test/decl/protocol/special/coding/struct_codable_simple.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,21 @@ let _ = SimpleStruct.encode(to:)
2929
// The synthesized CodingKeys type should not be accessible from outside the
3030
// struct.
3131
let _ = SimpleStruct.CodingKeys.self // expected-error {{'CodingKeys' is inaccessible due to 'private' protection level}}
32+
33+
// rdar://problem/59655704
34+
struct SR_12248_1: Codable { // expected-error {{type 'SR_12248_1' does not conform to protocol 'Encodable'}}
35+
var x: Int // expected-note {{'x' previously declared here}}
36+
var x: Int // expected-error {{invalid redeclaration of 'x'}}
37+
// expected-note@-1 {{cannot automatically synthesize 'Encodable' because '<<error type>>' does not conform to 'Encodable'}}
38+
// expected-note@-2 {{cannot automatically synthesize 'Encodable' because '<<error type>>' does not conform to 'Encodable'}}
39+
}
40+
41+
struct SR_12248_2: Decodable {
42+
var x: Int // expected-note {{'x' previously declared here}}
43+
var x: Int // expected-error {{invalid redeclaration of 'x'}}
44+
}
45+
46+
struct SR_12248_3: Encodable {
47+
var x: Int // expected-note {{'x' previously declared here}}
48+
var x: Int // expected-error {{invalid redeclaration of 'x'}}
49+
}

test/decl/var/property_wrappers.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,8 @@ struct WrapperWithProjectedValue<T> {
837837
class TestInvalidRedeclaration {
838838
@WrapperWithProjectedValue var i = 17
839839
// expected-note@-1 {{'i' previously declared here}}
840-
// expected-note@-2 {{'$i' previously declared here}}
841-
// expected-note@-3 {{'_i' previously declared here}}
842840
@WrapperWithProjectedValue var i = 39
843841
// expected-error@-1 {{invalid redeclaration of 'i'}}
844-
// expected-error@-2 {{invalid redeclaration of '$i'}}
845-
// expected-error@-3 {{invalid redeclaration of '_i'}}
846842
}
847843

848844
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)