Skip to content

Commit ceef760

Browse files
committed
---
yaml --- r: 344940 b: refs/heads/master c: 71c05cc h: refs/heads/master
1 parent f268d1e commit ceef760

File tree

13 files changed

+177
-40
lines changed

13 files changed

+177
-40
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ee59651b6314cf02c0c1719b905dfe7289a0b7b8
2+
refs/heads/master: 71c05cc9cb1ad21866b789876cb8408835cba6d1
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,12 @@ ERROR(type_does_not_conform_in_decl_ref,none,
15291529
ERROR(type_does_not_conform_decl_owner,none,
15301530
"%0 %1 requires that %2 conform to %3",
15311531
(DescriptiveDeclKind, DeclName, Type, Type))
1532+
ERROR(types_not_equal_decl,none,
1533+
"%0 %1 requires the types %2 and %3 be equivalent",
1534+
(DescriptiveDeclKind, DeclName, Type, Type))
1535+
ERROR(types_not_equal_in_decl_ref,none,
1536+
"referencing %0 %1 on %2 requires the types %3 and %4 be equivalent",
1537+
(DescriptiveDeclKind, DeclName, Type, Type, Type))
15321538
NOTE(where_requirement_failure_one_subst,none,
15331539
"where %0 = %1", (Type, Type))
15341540
NOTE(where_requirement_failure_both_subst,none,

trunk/lib/Sema/CSDiagnostics.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,42 @@ class MissingConformanceFailure final : public RequirementFailure {
226226
}
227227
};
228228

229+
/// Diagnose failures related to same-type generic requirements, e.g.
230+
/// ```swift
231+
/// protocol P {
232+
/// associatedtype T
233+
/// }
234+
///
235+
/// struct S : P {
236+
/// typealias T = String
237+
/// }
238+
///
239+
/// func foo<U: P>(_ t: [U]) where U.T == Int {}
240+
/// foo([S()])
241+
/// ```
242+
///
243+
/// `S.T` is not the same type as `Int`, which is required by `foo`.
244+
class SameTypeRequirementFailure final : public RequirementFailure {
245+
Type LHS, RHS;
246+
247+
public:
248+
SameTypeRequirementFailure(Expr *expr, const Solution &solution, Type lhs,
249+
Type rhs, ConstraintLocator *locator)
250+
: RequirementFailure(expr, solution, locator), LHS(lhs), RHS(rhs) {}
251+
252+
Type getLHS() const override { return LHS; }
253+
Type getRHS() const override { return RHS; }
254+
255+
protected:
256+
DiagOnDecl getDiagnosticOnDecl() const override {
257+
return diag::types_not_equal_decl;
258+
}
259+
260+
DiagInReference getDiagnosticInRereference() const override {
261+
return diag::types_not_equal_in_decl_ref;
262+
}
263+
};
264+
229265
/// Diagnose errors associated with missing, extraneous
230266
/// or incorrect labels supplied by arguments, e.g.
231267
/// ```swift

trunk/lib/Sema/CSFix.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,15 @@ MissingConformance *MissingConformance::create(ConstraintSystem &cs, Type type,
163163
ConstraintLocator *locator) {
164164
return new (cs.getAllocator()) MissingConformance(type, protocol, locator);
165165
}
166+
167+
bool SkipSameTypeRequirement::diagnose(Expr *root,
168+
const Solution &solution) const {
169+
SameTypeRequirementFailure failure(root, solution, LHS, RHS, getLocator());
170+
return failure.diagnose();
171+
}
172+
173+
SkipSameTypeRequirement *
174+
SkipSameTypeRequirement::create(ConstraintSystem &cs, Type lhs, Type rhs,
175+
ConstraintLocator *locator) {
176+
return new (cs.getAllocator()) SkipSameTypeRequirement(lhs, rhs, locator);
177+
}

trunk/lib/Sema/CSFix.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ enum class FixKind : uint8_t {
6666
/// labels attached to the, fix it by suggesting proper labels.
6767
RelabelArguments,
6868

69+
/// Treat rvalue as lvalue
70+
TreatRValueAsLValue,
71+
6972
/// Add a new conformance to the type to satisfy a requirement.
7073
AddConformance,
7174

72-
/// Treat rvalue as lvalue
73-
TreatRValueAsLValue,
75+
/// Skip same-type generic requirement constraint,
76+
/// and assume that types are equal.
77+
SkipSameTypeRequirement,
7478
};
7579

7680
class ConstraintFix {
@@ -277,6 +281,26 @@ class MissingConformance final : public ConstraintFix {
277281
ConstraintLocator *locator);
278282
};
279283

284+
/// Skip same-type generic requirement constraint,
285+
/// and assume that types are equal.
286+
class SkipSameTypeRequirement final : public ConstraintFix {
287+
Type LHS, RHS;
288+
289+
SkipSameTypeRequirement(Type lhs, Type rhs, ConstraintLocator *locator)
290+
: ConstraintFix(FixKind::SkipSameTypeRequirement, locator), LHS(lhs),
291+
RHS(rhs) {}
292+
293+
public:
294+
std::string getName() const override {
295+
return "skip same-type generic requirement";
296+
}
297+
298+
bool diagnose(Expr *root, const Solution &solution) const override;
299+
300+
static SkipSameTypeRequirement *create(ConstraintSystem &cs, Type lhs,
301+
Type rhs, ConstraintLocator *locator);
302+
};
303+
280304
} // end namespace constraints
281305
} // end namespace swift
282306

trunk/lib/Sema/CSSimplify.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,52 @@ ConstraintSystem::matchTypesBindTypeVar(
16251625
return getTypeMatchSuccess();
16261626
}
16271627

1628+
static void attemptToFixRequirementFailure(
1629+
ConstraintSystem &cs, Type type1, Type type2,
1630+
SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
1631+
ConstraintLocatorBuilder locator) {
1632+
using LocatorPathEltKind = ConstraintLocator::PathElementKind;
1633+
1634+
// Can't fix not yet properly resolved types.
1635+
if (type1->hasTypeVariable() || type2->hasTypeVariable())
1636+
return;
1637+
1638+
// If dependent members are present here it's because
1639+
// base doesn't conform to associated type's protocol.
1640+
if (type1->hasDependentMember() || type2->hasDependentMember())
1641+
return;
1642+
1643+
SmallVector<LocatorPathElt, 4> path;
1644+
auto *anchor = locator.getLocatorParts(path);
1645+
1646+
if (path.empty())
1647+
return;
1648+
1649+
auto &elt = path.back();
1650+
if (elt.getKind() != LocatorPathEltKind::TypeParameterRequirement)
1651+
return;
1652+
1653+
// Build simplified locator which only contains anchor and requirement info.
1654+
ConstraintLocatorBuilder requirement(cs.getConstraintLocator(anchor));
1655+
auto *reqLoc = cs.getConstraintLocator(requirement.withPathElement(elt));
1656+
1657+
auto reqKind = static_cast<RequirementKind>(elt.getValue2());
1658+
switch (reqKind) {
1659+
case RequirementKind::SameType: {
1660+
auto *fix = SkipSameTypeRequirement::create(cs, type1, type2, reqLoc);
1661+
conversionsOrFixes.push_back(fix);
1662+
return;
1663+
}
1664+
1665+
case RequirementKind::Superclass:
1666+
break; // Not yet supported
1667+
1668+
case RequirementKind::Conformance:
1669+
case RequirementKind::Layout:
1670+
llvm_unreachable("conformance requirements are handled elsewhere");
1671+
}
1672+
}
1673+
16281674
ConstraintSystem::TypeMatchResult
16291675
ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
16301676
TypeMatchOptions flags,
@@ -2452,6 +2498,10 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
24522498
}
24532499
}
24542500

2501+
if (attemptFixes)
2502+
attemptToFixRequirementFailure(*this, type1, type2, conversionsOrFixes,
2503+
locator);
2504+
24552505
if (conversionsOrFixes.empty()) {
24562506
// If one of the types is a type variable or member thereof, we leave this
24572507
// unsolved.
@@ -4996,6 +5046,10 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
49965046
return result;
49975047
}
49985048

5049+
case FixKind::SkipSameTypeRequirement: {
5050+
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
5051+
}
5052+
49995053
case FixKind::ExplicitlyEscaping:
50005054
case FixKind::CoerceToCheckedCast:
50015055
case FixKind::RelabelArguments:

trunk/test/Constraints/conditionally_defined_types.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct Z2: AssociatedType {
1515
}
1616

1717
struct SameType<T> {}
18-
extension SameType where T == X {
18+
extension SameType where T == X { // expected-note 5 {{where 'T' = 'Y'}}
1919
typealias TypeAlias1 = T
2020
typealias TypeAlias2 = Y
2121
typealias TypeAlias3<U> = (T, U) // expected-note {{requirement specified as 'T' == 'X' [with T = Y]}}
@@ -36,20 +36,20 @@ let _ = SameType<X>.Decl3.self
3636
let _ = SameType<X>.Decl4<X>.self
3737
let _ = SameType<X>.Decl5<X>.self
3838

39-
let _ = SameType<Y>.TypeAlias1.self // expected-error {{'SameType<Y>.TypeAlias1.Type' (aka 'X.Type') requires the types 'Y' and 'X' be equivalent}}
40-
let _ = SameType<Y>.TypeAlias2.self // expected-error {{'SameType<Y>.TypeAlias2.Type' (aka 'Y.Type') requires the types 'Y' and 'X' be equivalent}}
39+
let _ = SameType<Y>.TypeAlias1.self // expected-error {{referencing type alias 'TypeAlias1' on 'SameType' requires the types 'Y' and 'X' be equivalent}}
40+
let _ = SameType<Y>.TypeAlias2.self // expected-error {{referencing type alias 'TypeAlias2' on 'SameType' requires the types 'Y' and 'X' be equivalent}}
4141
let _ = SameType<Y>.TypeAlias3<X>.self // expected-error {{'SameType<Y>.TypeAlias3' requires the types 'Y' and 'X' be equivalent}}
42-
let _ = SameType<Y>.Decl1.self // expected-error {{'SameType<Y>.Decl1.Type' requires the types 'Y' and 'X' be equivalent}}
43-
let _ = SameType<Y>.Decl2.self // expected-error {{'SameType<Y>.Decl2.Type' requires the types 'Y' and 'X' be equivalent}}
44-
let _ = SameType<Y>.Decl3.self // expected-error {{'SameType<Y>.Decl3.Type' requires the types 'Y' and 'X' be equivalent}}
42+
let _ = SameType<Y>.Decl1.self // expected-error {{referencing struct 'Decl1' on 'SameType' requires the types 'Y' and 'X' be equivalent}}
43+
let _ = SameType<Y>.Decl2.self // expected-error {{referencing enum 'Decl2' on 'SameType' requires the types 'Y' and 'X' be equivalent}}
44+
let _ = SameType<Y>.Decl3.self // expected-error {{referencing class 'Decl3' on 'SameType' requires the types 'Y' and 'X' be equivalent}}
4545
let _ = SameType<Y>.Decl4<X>.self // expected-error {{'SameType<Y>.Decl4' requires the types 'Y' and 'X' be equivalent}}
4646
let _ = SameType<Y>.Decl5<X>.self // expected-error {{'SameType<Y>.Decl5' requires the types 'Y' and 'X' be equivalent}}
4747

48-
extension SameType: AssociatedType where T == X {}
48+
extension SameType: AssociatedType where T == X {} // expected-note {{where 'T' = 'Y'}}
4949

5050
// (Y first here, because there were issues caused by running associated type
5151
// inference for the first time)
52-
let _ = SameType<Y>.T.self // expected-error {{'SameType<Y>.T.Type' (aka 'X.Type') requires the types 'Y' and 'X' be equivalent}}
52+
let _ = SameType<Y>.T.self // expected-error {{referencing type alias 'T' on 'SameType' requires the types 'Y' and 'X' be equivalent}}
5353

5454
let _ = SameType<X>.T.self
5555

@@ -92,7 +92,7 @@ let _ = Conforms<X>.T.self
9292

9393
// Now, even more nesting!
9494

95-
extension SameType.Decl1 {
95+
extension SameType.Decl1 { // expected-note 5 {{where 'T' = 'Y'}}
9696
typealias TypeAlias1 = T
9797
typealias TypeAlias2 = Y
9898
typealias TypeAlias3<U> = (T, U) // expected-note {{requirement specified as 'T' == 'X' [with T = Y]}}
@@ -113,16 +113,16 @@ let _ = SameType<X>.Decl1.Decl3.self
113113
let _ = SameType<X>.Decl1.Decl4<X>.self
114114
let _ = SameType<X>.Decl1.Decl5<X>.self
115115

116-
let _ = SameType<Y>.Decl1.TypeAlias1.self // expected-error {{'SameType<Y>.Decl1.TypeAlias1.Type' (aka 'X.Type') requires the types 'Y' and 'X' be equivalent}}
117-
let _ = SameType<Y>.Decl1.TypeAlias2.self // expected-error {{'SameType<Y>.Decl1.TypeAlias2.Type' (aka 'Y.Type') requires the types 'Y' and 'X' be equivalent}}
116+
let _ = SameType<Y>.Decl1.TypeAlias1.self // expected-error {{referencing type alias 'TypeAlias1' on 'SameType.Decl1' requires the types 'Y' and 'X' be equivalent}}
117+
let _ = SameType<Y>.Decl1.TypeAlias2.self // expected-error {{referencing type alias 'TypeAlias2' on 'SameType.Decl1' requires the types 'Y' and 'X' be equivalent}}
118118
let _ = SameType<Y>.Decl1.TypeAlias3<X>.self // expected-error {{'SameType<Y>.Decl1.TypeAlias3' requires the types 'Y' and 'X' be equivalent}}
119-
let _ = SameType<Y>.Decl1.Decl1.self // expected-error {{'SameType<Y>.Decl1.Decl1.Type' requires the types 'Y' and 'X' be equivalent}}
120-
let _ = SameType<Y>.Decl1.Decl2.self // expected-error {{'SameType<Y>.Decl1.Decl2.Type' requires the types 'Y' and 'X' be equivalent}}
121-
let _ = SameType<Y>.Decl1.Decl3.self // expected-error {{'SameType<Y>.Decl1.Decl3.Type' requires the types 'Y' and 'X' be equivalent}}
119+
let _ = SameType<Y>.Decl1.Decl1.self // expected-error {{referencing struct 'Decl1' on 'SameType.Decl1' requires the types 'Y' and 'X' be equivalent}}
120+
let _ = SameType<Y>.Decl1.Decl2.self // expected-error {{referencing enum 'Decl2' on 'SameType.Decl1' requires the types 'Y' and 'X' be equivalent}}
121+
let _ = SameType<Y>.Decl1.Decl3.self // expected-error {{referencing class 'Decl3' on 'SameType.Decl1' requires the types 'Y' and 'X' be equivalent}}
122122
let _ = SameType<Y>.Decl1.Decl4<X>.self // expected-error {{'SameType<Y>.Decl1.Decl4' requires the types 'Y' and 'X' be equivalent}}
123123
let _ = SameType<Y>.Decl1.Decl5<X>.self // expected-error {{'SameType<Y>.Decl1.Decl5' requires the types 'Y' and 'X' be equivalent}}
124124

125-
extension SameType.Decl4 where U == X {
125+
extension SameType.Decl4 where U == X { // expected-note 5 {{where 'U' = 'Y'}}
126126
typealias TypeAlias1 = T
127127
typealias TypeAlias2 = Y
128128
typealias TypeAlias3<V> = (T, U, V) // expected-note {{requirement specified as 'U' == 'X' [with U = Y]}}
@@ -145,12 +145,12 @@ let _ = SameType<X>.Decl4<X>.Decl3.self
145145
let _ = SameType<X>.Decl4<X>.Decl4<X>.self
146146
let _ = SameType<X>.Decl4<X>.Decl5<X>.self
147147

148-
let _ = SameType<X>.Decl4<Y>.TypeAlias1.self // expected-error {{'SameType<X>.Decl4<Y>.TypeAlias1.Type' (aka 'X.Type') requires the types 'Y' and 'X' be equivalent}}
149-
let _ = SameType<X>.Decl4<Y>.TypeAlias2.self // expected-error {{'SameType<X>.Decl4<Y>.TypeAlias2.Type' (aka 'Y.Type') requires the types 'Y' and 'X' be equivalent}}
148+
let _ = SameType<X>.Decl4<Y>.TypeAlias1.self // expected-error {{referencing type alias 'TypeAlias1' on 'SameType.Decl4' requires the types 'Y' and 'X' be equivalent}}
149+
let _ = SameType<X>.Decl4<Y>.TypeAlias2.self // expected-error {{referencing type alias 'TypeAlias2' on 'SameType.Decl4' requires the types 'Y' and 'X' be equivalent}}
150150
let _ = SameType<X>.Decl4<Y>.TypeAlias3<X>.self // expected-error {{'SameType<X>.Decl4<Y>.TypeAlias3' requires the types 'Y' and 'X' be equivalent}}
151-
let _ = SameType<X>.Decl4<Y>.Decl1.self // expected-error {{'SameType<X>.Decl4<Y>.Decl1.Type' requires the types 'Y' and 'X' be equivalent}}
152-
let _ = SameType<X>.Decl4<Y>.Decl2.self // expected-error {{'SameType<X>.Decl4<Y>.Decl2.Type' requires the types 'Y' and 'X' be equivalent}}
153-
let _ = SameType<X>.Decl4<Y>.Decl3.self // expected-error {{'SameType<X>.Decl4<Y>.Decl3.Type' requires the types 'Y' and 'X' be equivalent}}
151+
let _ = SameType<X>.Decl4<Y>.Decl1.self // expected-error {{referencing struct 'Decl1' on 'SameType.Decl4' requires the types 'Y' and 'X' be equivalent}}
152+
let _ = SameType<X>.Decl4<Y>.Decl2.self // expected-error {{referencing enum 'Decl2' on 'SameType.Decl4' requires the types 'Y' and 'X' be equivalent}}
153+
let _ = SameType<X>.Decl4<Y>.Decl3.self // expected-error {{referencing class 'Decl3' on 'SameType.Decl4' requires the types 'Y' and 'X' be equivalent}}
154154
let _ = SameType<X>.Decl4<Y>.Decl4<X>.self // expected-error {{'SameType<X>.Decl4<Y>.Decl4' requires the types 'Y' and 'X' be equivalent}}
155155
let _ = SameType<X>.Decl4<Y>.Decl5<X>.self // expected-error {{'SameType<X>.Decl4<Y>.Decl5' requires the types 'Y' and 'X' be equivalent}}
156156

trunk/test/Constraints/diagnostics.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,7 @@ func platypus<T>(a: [T]) {
11981198
func badTypes() {
11991199
let sequence:AnySequence<[Int]> = AnySequence() { AnyIterator() { [3] }}
12001200
let array = [Int](sequence)
1201-
// expected-error@-1 {{type of expression is ambiguous without more context}}
1202-
// FIXME: terrible diagnostic
1201+
// expected-error@-1 {{initializer 'init' requires the types 'Int' and '[Int]' be equivalent}}
12031202
}
12041203

12051204
// rdar://34357545

trunk/test/Constraints/generics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ struct S27515965 : P27515965 {
248248

249249
struct V27515965 {
250250
init<T : P27515965>(_ tp: T) where T.R == Float {}
251-
// expected-note@-1 {{candidate requires that the types 'Any' and 'Float' be equivalent (requirement specified as 'T.R' == 'Float' [with T = S27515965])}}
251+
// expected-note@-1 {{where 'T.R' = 'Any'}}
252252
}
253253

254254
func test(x: S27515965) -> V27515965 {
255255
return V27515965(x)
256-
// expected-error@-1 {{cannot invoke initializer for type 'init(_:)' with an argument list of type '(S27515965)'}}
256+
// expected-error@-1 {{initializer 'init' requires the types 'Any' and 'Float' be equivalent}}
257257
}
258258

259259
protocol BaseProto {}

trunk/test/Constraints/rdar39931339.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension S where T : P {
1313
typealias B<U> = S<U>
1414
}
1515

16-
extension S where T == Float {
16+
extension S where T == Float { // expected-note {{where 'T' = 'Int'}}
1717
typealias C = Int
1818
}
1919

@@ -24,6 +24,8 @@ extension A where T == [U], U: P { // expected-note {{where 'U' = 'Float'}}
2424
}
2525

2626
extension A where T == [U], U == Int {
27+
// expected-note@-1 {{where 'U' = 'String'}}
28+
// expected-note@-2 {{where 'T' = '[String]'}}
2729
typealias S2 = Int
2830
}
2931

@@ -32,12 +34,14 @@ class B<U> : A<[U], U> {}
3234
_ = B<C>.S1() // Ok
3335
_ = B<Int>.S2() // Ok
3436
_ = B<Float>.S1() // expected-error {{referencing type alias 'S1' on 'A' requires that 'Float' conform to 'P'}}
35-
_ = B<String>.S2() // expected-error {{'B<String>.S2.Type' (aka 'Int.Type') requires the types '[String]' and '[Int]' be equivalent}}
37+
_ = B<String>.S2()
38+
// expected-error@-1 {{referencing type alias 'S2' on 'A' requires the types '[String]' and '[Int]' be equivalent}}
39+
// expected-error@-2 {{referencing type alias 'S2' on 'A' requires the types 'String' and 'Int' be equivalent}}
3640

3741
_ = S<C>.A() // Ok
3842
_ = S<Int>.A() // expected-error {{referencing type alias 'A' on 'S' requires that 'Int' conform to 'P'}}
3943
_ = S<String>.B<Int>() // expected-error {{type 'String' does not conform to protocol 'P'}}
40-
_ = S<Int>.C() // expected-error {{'S<Int>.C.Type' (aka 'Int.Type') requires the types 'Int' and 'Float' be equivalent}}
44+
_ = S<Int>.C() // expected-error {{referencing type alias 'C' on 'S' requires the types 'Int' and 'Float' be equivalent}}
4145

4246
func foo<T>(_ s: S<T>.Type) {
4347
_ = s.A() // expected-error {{referencing type alias 'A' on 'S' requires that 'T' conform to 'P'}}

trunk/test/Constraints/tuple.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ protocol Kingdom {
162162
associatedtype King
163163
}
164164
struct Victory<General> {
165-
init<K: Kingdom>(_ king: K) where K.King == General {}
165+
init<K: Kingdom>(_ king: K) where K.King == General {} // expected-note {{where 'General' = '(x: Int, y: Int)', 'K.King' = '(Int, Int)'}}
166166
}
167167
struct MagicKingdom<K> : Kingdom {
168168
typealias King = K
169169
}
170170
func magify<T>(_ t: T) -> MagicKingdom<T> { return MagicKingdom() }
171171
func foo(_ pair: (Int, Int)) -> Victory<(x: Int, y: Int)> {
172-
return Victory(magify(pair)) // expected-error {{cannot convert return expression of type 'Victory<(Int, Int)>' to return type 'Victory<(x: Int, y: Int)>'}}
172+
return Victory(magify(pair)) // expected-error {{initializer 'init' requires the types '(x: Int, y: Int)' and '(Int, Int)' be equivalent}}
173173
}
174174

175175

trunk/test/Generics/deduction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ func callRangeOfIsBefore(_ ia: [Int], da: [Double]) {
218218
}
219219

220220
func testEqualIterElementTypes<A: IteratorProtocol, B: IteratorProtocol>(_ a: A, _ b: B) where A.Element == B.Element {}
221-
// expected-note@-1 {{candidate requires that the types 'Int' and 'Double' be equivalent (requirement specified as 'A.Element' == 'B.Element' [with A = IndexingIterator<[Int]>, B = IndexingIterator<[Double]>])}}
221+
// expected-note@-1 {{where 'A.Element' = 'Int', 'B.Element' = 'Double'}}
222222
func compareIterators() {
223223
var a: [Int] = []
224224
var b: [Double] = []
225225
testEqualIterElementTypes(a.makeIterator(), b.makeIterator())
226-
// expected-error@-1 {{cannot invoke 'testEqualIterElementTypes(_:_:)' with an argument list of type '(IndexingIterator<[Int]>, IndexingIterator<[Double]>)'}}
226+
// expected-error@-1 {{global function 'testEqualIterElementTypes' requires the types 'Int' and 'Double' be equivalent}}
227227
}
228228

229229
protocol P_GI {

0 commit comments

Comments
 (0)