Skip to content

Commit 5cfb8e8

Browse files
committed
[Diagnostics] Fix generic arguments mismatch diagnostic related to leading-dot syntax
`GenericArgumentsMismatchFailure` missed a case where location of the failure points to a member spelled with leading-dot syntax.
1 parent c2a0cc7 commit 5cfb8e8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,8 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
10371037
break;
10381038
}
10391039

1040-
case ConstraintLocator::Member: {
1040+
case ConstraintLocator::Member:
1041+
case ConstraintLocator::UnresolvedMember: {
10411042
auto *memberLoc = getConstraintLocator(anchor, path);
10421043
auto selectedOverload = getOverloadChoiceIfAvailable(memberLoc);
10431044
if (!selectedOverload)

test/Concurrency/sendable_to_any_for_generic_arguments.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,17 @@ func test_subscript_computed_property_and_mutating_access(u: User) {
175175

176176
u.dict.testMutating() // Ok
177177
}
178+
179+
extension Dictionary where Key == String, Value == Any {
180+
init(age: Int) { // expected-note {{'init(age:)' declared here}}
181+
self.init()
182+
}
183+
}
184+
185+
extension User {
186+
convenience init(age: Int) {
187+
self.init()
188+
self.dict = .init(age: age)
189+
// expected-error@-1 {{referencing initializer 'init(age:)' on '[String : any Sendable].Type' requires the types 'any Sendable' and 'Any' be equivalent}}
190+
}
191+
}

0 commit comments

Comments
 (0)