Skip to content

Commit ed9e2d6

Browse files
authored
Merge pull request #64398 from xedin/rdar-106621760
[CSDiagnostics] Ignore placeholder types that appear in editor placeh…
2 parents c088196 + d1badfe commit ed9e2d6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8322,6 +8322,13 @@ bool CouldNotInferPlaceholderType::diagnoseAsError() {
83228322
}
83238323
}
83248324

8325+
// When placeholder type appears in an editor placeholder i.e.
8326+
// `<#T##() -> _#>` we rely on the parser to produce a diagnostic
8327+
// about editor placeholder and glance over all placeholder type
8328+
// inference issues.
8329+
if (isExpr<EditorPlaceholderExpr>(getAnchor()))
8330+
return true;
8331+
83258332
return false;
83268333
}
83278334

test/Sema/placeholder_type.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,16 @@ func deferredInit(_ c: Bool) {
270270
// https://github.com/apple/swift/issues/63130
271271
let _: _ = nil // expected-error{{'nil' requires a contextual type}}
272272
let _: _? = nil // expected-error{{'nil' requires a contextual type}}
273+
274+
// rdar://106621760 - failed to produce a diagnostic when placeholder type appears in editor placeholder
275+
do {
276+
struct X<T> {
277+
init(content: () -> T) {}
278+
}
279+
280+
func test(_: () -> Void) {}
281+
282+
test {
283+
_ = X(content: <#T##() -> _#>) // expected-error {{editor placeholder in source file}}
284+
}
285+
}

0 commit comments

Comments
 (0)