Skip to content

Commit da0e5f2

Browse files
Adjusting unit tests
1 parent 9043456 commit da0e5f2

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -971,15 +971,8 @@ bool NoEscapeFuncToTypeConversionFailure::diagnoseParameterUse() const {
971971
}
972972

973973
bool MissingForcedDowncastFailure::diagnoseAsError() {
974-
bool isExplicitCoercion =
975-
getLocator()
976-
->isLastElement<
977-
ConstraintLocator::PathElement::ExplicitTypeCoercion>();
978-
979-
if (!isExplicitCoercion) {
980-
if (hasComplexLocator())
981-
return false;
982-
}
974+
if (hasComplexLocator())
975+
return false;
983976

984977
auto *expr = getAnchor();
985978
if (auto *assignExpr = dyn_cast<AssignExpr>(expr))

lib/Sema/CSDiagnostics.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,13 @@ class FailureDiagnostic {
156156
}
157157

158158
/// \returns true is locator hasn't been simplified down to expression.
159-
bool hasComplexLocator() const { return HasComplexLocator; }
159+
bool hasComplexLocator() const {
160+
bool isExplicitCoercion =
161+
getLocator()
162+
->isLastElement<
163+
ConstraintLocator::PathElement::ExplicitTypeCoercion>();
164+
return HasComplexLocator && !isExplicitCoercion;
165+
}
160166

161167
/// \returns A parent expression if sub-expression is contained anywhere
162168
/// in the root expression or `nullptr` otherwise.

test/ClangImporter/objc_parse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ func testProtocolQualified(_ obj: CopyableNSObject, cell: CopyableSomeCell,
550550
_ = cell as NSCopying
551551
_ = cell as SomeCell
552552

553-
_ = plainObj as CopyableNSObject // expected-error {{'NSObject' is not convertible to 'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol'); did you mean to use 'as!' to force downcast?}} {{16-18=as!}}
554-
_ = plainCell as CopyableSomeCell // expected-error {{'SomeCell' is not convertible to 'CopyableSomeCell' (aka 'SomeCell & NSCopying'); did you mean to use 'as!' to force downcast?}}
553+
_ = plainObj as CopyableNSObject // expected-error {{value of type 'NSObject' does not conform to 'NSCopying' in coercion}}
554+
_ = plainCell as CopyableSomeCell // expected-error {{value of type 'SomeCell' does not conform to 'NSCopying' in coercion}}
555555
}
556556

557557
extension Printing {

test/Generics/function_defs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func otherExistential<T : EqualComparable>(_ t1: T) {
5353
otherEqComp2 = t1 // expected-error{{value of type 'T' does not conform to 'OtherEqualComparable' in assignment}}
5454
_ = otherEqComp2
5555

56-
_ = t1 as EqualComparable & OtherEqualComparable // expected-error{{'T' is not convertible to 'EqualComparable & OtherEqualComparable'; did you mean to use 'as!' to force downcast?}} {{10-12=as!}} expected-error{{protocol 'OtherEqualComparable' can only be used as a generic constraint}} expected-error{{protocol 'EqualComparable' can only be used as a generic constraint}}
56+
_ = t1 as EqualComparable & OtherEqualComparable // expected-error{{value of type 'T' does not conform to 'OtherEqualComparable' in coercion}} expected-error{{protocol 'OtherEqualComparable' can only be used as a generic constraint}} expected-error{{protocol 'EqualComparable' can only be used as a generic constraint}}
5757
}
5858

5959
protocol Runcible {

test/decl/protocol/protocols.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct Circle {
118118
func testCircular(_ circle: Circle) {
119119
// FIXME: It would be nice if this failure were suppressed because the protocols
120120
// have circular definitions.
121-
_ = circle as CircleStart // expected-error{{'Circle' is not convertible to 'CircleStart'; did you mean to use 'as!' to force downcast?}} {{14-16=as!}}
121+
_ = circle as CircleStart // expected-error{{value of type 'Circle' does not conform to 'CircleStart' in coercion}}
122122
}
123123

124124
// <rdar://problem/14750346>
@@ -482,7 +482,7 @@ func f<T : C1>(_ x : T) {
482482

483483
class C2 {}
484484
func g<T : C2>(_ x : T) {
485-
x as P2 // expected-error{{'T' is not convertible to 'P2'; did you mean to use 'as!' to force downcast?}} {{5-7=as!}}
485+
x as P2 // expected-error {{value of type 'T' does not conform to 'P2' in coercion}}
486486
}
487487

488488
class C3 : P1 {} // expected-error{{type 'C3' does not conform to protocol 'P1'}}

0 commit comments

Comments
 (0)