Skip to content

[Sema] Do not attempt warn extraneous checked cast for placeholder types #37057

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
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
3 changes: 2 additions & 1 deletion lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6442,7 +6442,8 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
return nullptr;

// Both types have to be fixed.
if (fromType->hasTypeVariable() || toType->hasTypeVariable())
if (fromType->hasTypeVariable() || toType->hasTypeVariable() ||
fromType->hasPlaceholder() || toType->hasPlaceholder())
return nullptr;

SmallVector<LocatorPathElt, 4> path;
Expand Down
6 changes: 6 additions & 0 deletions test/Constraints/casts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,9 @@ let _ = derived is (SR13899_Derived) -> Void // expected-warning{{'is' test is a
let _ = derived is (SR13899_Derived) throws -> Void // expected-warning{{'is' test is always true}}
let _ = blockp is (SR13899_A) -> Void //expected-warning{{'is' test is always true}}
let _ = blockp is (SR13899_A) throws -> Void //expected-warning{{'is' test is always true}}

protocol PP1 { }
protocol PP2: PP1 { }
extension Optional: PP1 where Wrapped == PP2 { }

nil is PP1 // expected-error {{'nil' requires a contextual type}}