Skip to content

Commit d1badfe

Browse files
committed
[CSDiagnostics] Ignore placeholder types that appear in editor placeholder expressions
When placeholder type appears in an editor placeholder i.e. `<#T##() -> _#>` we rely on the parser to produce a diagnostic about editor placeholder and glance over all placeholer type inference issues. Resolves: rdar://106621760
1 parent ed5984a commit d1badfe

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
@@ -8176,6 +8176,13 @@ bool CouldNotInferPlaceholderType::diagnoseAsError() {
81768176
}
81778177
}
81788178

8179+
// When placeholder type appears in an editor placeholder i.e.
8180+
// `<#T##() -> _#>` we rely on the parser to produce a diagnostic
8181+
// about editor placeholder and glance over all placeholder type
8182+
// inference issues.
8183+
if (isExpr<EditorPlaceholderExpr>(getAnchor()))
8184+
return true;
8185+
81798186
return false;
81808187
}
81818188

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)