Skip to content

Commit c15dde4

Browse files
Merge pull request #37057 from LucianoPAlmeida/placeholder-checkedcast-warn
[Sema] Do not attempt warn extraneous checked cast for placeholder types
2 parents 02821fd + b851974 commit c15dde4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6448,7 +6448,8 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
64486448
return nullptr;
64496449

64506450
// Both types have to be fixed.
6451-
if (fromType->hasTypeVariable() || toType->hasTypeVariable())
6451+
if (fromType->hasTypeVariable() || toType->hasTypeVariable() ||
6452+
fromType->hasPlaceholder() || toType->hasPlaceholder())
64526453
return nullptr;
64536454

64546455
SmallVector<LocatorPathElt, 4> path;

test/Constraints/casts.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,3 +529,9 @@ let _ = derived is (SR13899_Derived) -> Void // expected-warning{{'is' test is a
529529
let _ = derived is (SR13899_Derived) throws -> Void // expected-warning{{'is' test is always true}}
530530
let _ = blockp is (SR13899_A) -> Void //expected-warning{{'is' test is always true}}
531531
let _ = blockp is (SR13899_A) throws -> Void //expected-warning{{'is' test is always true}}
532+
533+
protocol PP1 { }
534+
protocol PP2: PP1 { }
535+
extension Optional: PP1 where Wrapped == PP2 { }
536+
537+
nil is PP1 // expected-error {{'nil' requires a contextual type}}

0 commit comments

Comments
 (0)