Merge pull request #37057 from LucianoPAlmeida/placeholder-checkedcast-warn

[Sema] Do not attempt warn extraneous checked cast for placeholder types
This commit is contained in:
Luciano Almeida
2021-04-25 08:03:18 -03:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -6448,7 +6448,8 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
return nullptr; return nullptr;
// Both types have to be fixed. // Both types have to be fixed.
if (fromType->hasTypeVariable() || toType->hasTypeVariable()) if (fromType->hasTypeVariable() || toType->hasTypeVariable() ||
fromType->hasPlaceholder() || toType->hasPlaceholder())
return nullptr; return nullptr;
SmallVector<LocatorPathElt, 4> path; SmallVector<LocatorPathElt, 4> path;

View File

@@ -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 _ = 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) -> Void //expected-warning{{'is' test is always true}}
let _ = blockp is (SR13899_A) throws -> 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}}