Skip to content

[TypeChecker] <unknown> diagnostic location regarding Codable derived conformances #31037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckDeclPrimary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
current->diagnose(diag::invalid_redecl_init,
current->getFullName(),
otherInit->isMemberwiseInitializer());
} else {
} else if (!current->isImplicit() && !other->isImplicit()) {
ctx.Diags.diagnoseWithNotes(
current->diagnose(diag::invalid_redecl,
current->getFullName()), [&]() {
Expand Down
2 changes: 1 addition & 1 deletion test/Sema/enum_conformance_synthesis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func customHashable() {
enum InvalidCustomHashable {
case A, B

var hashValue: String { return "" } // expected-note {{previously declared here}}
var hashValue: String { return "" }
}
func ==(x: InvalidCustomHashable, y: InvalidCustomHashable) -> String {
return ""
Expand Down
18 changes: 18 additions & 0 deletions test/decl/protocol/special/coding/struct_codable_simple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@ let _ = SimpleStruct.encode(to:)
// The synthesized CodingKeys type should not be accessible from outside the
// struct.
let _ = SimpleStruct.CodingKeys.self // expected-error {{'CodingKeys' is inaccessible due to 'private' protection level}}

// rdar://problem/59655704
struct SR_12248_1: Codable { // expected-error {{type 'SR_12248_1' does not conform to protocol 'Encodable'}}
var x: Int // expected-note {{'x' previously declared here}}
var x: Int // expected-error {{invalid redeclaration of 'x'}}
// expected-note@-1 {{cannot automatically synthesize 'Encodable' because '<<error type>>' does not conform to 'Encodable'}}
// expected-note@-2 {{cannot automatically synthesize 'Encodable' because '<<error type>>' does not conform to 'Encodable'}}
}

struct SR_12248_2: Decodable {
var x: Int // expected-note {{'x' previously declared here}}
var x: Int // expected-error {{invalid redeclaration of 'x'}}
}

struct SR_12248_3: Encodable {
var x: Int // expected-note {{'x' previously declared here}}
var x: Int // expected-error {{invalid redeclaration of 'x'}}
}
4 changes: 0 additions & 4 deletions test/decl/var/property_wrappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,8 @@ struct WrapperWithProjectedValue<T> {
class TestInvalidRedeclaration {
@WrapperWithProjectedValue var i = 17
// expected-note@-1 {{'i' previously declared here}}
// expected-note@-2 {{'$i' previously declared here}}
// expected-note@-3 {{'_i' previously declared here}}
@WrapperWithProjectedValue var i = 39
// expected-error@-1 {{invalid redeclaration of 'i'}}
// expected-error@-2 {{invalid redeclaration of '$i'}}
// expected-error@-3 {{invalid redeclaration of '_i'}}
}

// ---------------------------------------------------------------------------
Expand Down