Skip to content

Commit 5973013

Browse files
authored
Merge pull request #69617 from xedin/rdar-116522161
[CSFix] Allow `invalid property wrapper type` to be diagnosed in ambi…
2 parents b0105e1 + cd05971 commit 5973013

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/swift/Sema/CSFix.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,10 @@ class AllowInvalidPropertyWrapperType final : public ConstraintFix {
13681368
return "allow invalid property wrapper type";
13691369
}
13701370

1371+
bool diagnoseForAmbiguity(CommonFixesArray commonFixes) const override {
1372+
return diagnose(*commonFixes.front().first);
1373+
}
1374+
13711375
bool diagnose(const Solution &solution, bool asNote = false) const override;
13721376

13731377
static bool classof(const ConstraintFix *fix) {

test/Sema/property_wrapper_parameter_invalid.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,15 @@ func testInvalidWrapperInference() {
279279
// expected-error@+1 {{contextual closure type '() -> Void' expects 0 arguments, but 1 was used in closure body}}
280280
testExtraParameter { $value in }
281281
}
282+
283+
// rdar://116522161 - failed to produce a diagnostic on invalid projection use
284+
func testInvalidProjectionInAmbiguousContext() {
285+
func test<T>(_: [T], _: (T) -> Void) {}
286+
287+
func ambiguous() -> Int { 42 }
288+
func ambiguous() -> String { "" }
289+
290+
test([42]) { $v in // expected-error {{inferred projection type 'Int' is not a property wrapper}}
291+
ambiguous()
292+
}
293+
}

0 commit comments

Comments
 (0)