Skip to content

Commit b189b8a

Browse files
authored
Merge pull request #81936 from xedin/improve-optional-wrappedValue-mismatch-diagnostics
[CSSimplify] Fix `matchDeepEqualityTypes` to allow fixing of optionals
2 parents d1a97f1 + 4132aa0 commit b189b8a

28 files changed

+165
-62
lines changed

include/swift/Sema/CSFix.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ class ConstraintFix {
560560
return false;
561561
}
562562

563+
template <typename E>
564+
bool directlyAt() const {
565+
return getLocator()->directlyAt<E>();
566+
}
567+
563568
void print(llvm::raw_ostream &Out) const;
564569

565570
SWIFT_DEBUG_DUMP;

lib/Sema/CSDiagnostics.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,12 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
11141114
if (!diagnostic)
11151115
return false;
11161116

1117-
emitDiagnosticAt(::getLoc(anchor), *diagnostic, fromType, toType);
1117+
{
1118+
auto diag =
1119+
emitDiagnosticAt(::getLoc(anchor), *diagnostic, fromType, toType);
1120+
(void)tryFixIts(diag);
1121+
}
1122+
11181123
emitNotesForMismatches();
11191124
return true;
11201125
}

lib/Sema/CSSimplify.cpp

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4039,6 +4039,12 @@ ConstraintSystem::matchDeepEqualityTypes(Type type1, Type type2,
40394039
getConstraintLocator(locator, {LocatorPathElt::GenericType(type1),
40404040
LocatorPathElt::GenericType(type2)});
40414041

4042+
// Optionals have a lot of special diagnostics and only one
4043+
// generic argument so if we're dealing with one, let's allow
4044+
// `repairFailures` to take care of it.
4045+
if (bound1->getDecl()->isOptionalDecl())
4046+
return matchDeepTypeArguments(*this, subflags, args1, args2, baseLoc);
4047+
40424048
auto argMatchingFlags = subflags;
40434049
// Allow the solver to produce separate fixes while matching
40444050
// key path's root/value to a contextual type instead of the
@@ -4049,13 +4055,6 @@ ConstraintSystem::matchDeepEqualityTypes(Type type1, Type type2,
40494055
argMatchingFlags |= TMF_MatchingGenericArguments;
40504056
}
40514057

4052-
// Optionals have a lot of special diagnostics and only one
4053-
// generic argument so if we' re dealing with one, don't produce generic
4054-
// arguments mismatch fixes.
4055-
if (bound1->getDecl()->isOptionalDecl())
4056-
return matchDeepTypeArguments(*this, argMatchingFlags, args1, args2,
4057-
baseLoc);
4058-
40594058
SmallVector<unsigned, 4> mismatches;
40604059
auto result = matchDeepTypeArguments(
40614060
*this, argMatchingFlags, args1, args2, baseLoc,
@@ -6943,12 +6942,19 @@ bool ConstraintSystem::repairFailures(
69436942
path.pop_back();
69446943

69456944
ConstraintFix *fix = nullptr;
6946-
if (!path.empty() && path.back().is<LocatorPathElt::AnyRequirement>()) {
6945+
auto *fixLoc = getConstraintLocator(anchor, path);
6946+
6947+
if (fixLoc->isLastElement<LocatorPathElt::AnyRequirement>()) {
69476948
fix = fixRequirementFailure(*this, fromType, toType, anchor, path);
6949+
} else if (fixLoc->isLastElement<LocatorPathElt::TupleElement>()) {
6950+
return repairFailures(lhs, rhs, matchKind, flags, conversionsOrFixes,
6951+
fixLoc);
6952+
} else if (!lhs->mayHaveSuperclass() && rhs->isAnyObject()) {
6953+
fix = AllowNonClassTypeToConvertToAnyObject::create(*this, fromType,
6954+
fixLoc);
69486955
} else {
69496956
fix = GenericArgumentsMismatch::create(
6950-
*this, fromType, toType, {genericArgElt.getIndex()},
6951-
getConstraintLocator(anchor, path));
6957+
*this, fromType, toType, {genericArgElt.getIndex()}, fixLoc);
69526958
}
69536959

69546960
if (!fix)
@@ -15688,14 +15694,31 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1568815694
case FixKind::AllowFunctionSpecialization:
1568915695
case FixKind::IgnoreGenericSpecializationArityMismatch:
1569015696
case FixKind::IgnoreKeyPathSubscriptIndexMismatch:
15691-
case FixKind::AllowMemberRefOnExistential: {
15697+
case FixKind::AllowMemberRefOnExistential:
15698+
case FixKind::AllowNonClassTypeToConvertToAnyObject: {
1569215699
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
1569315700
}
1569415701

1569515702
case FixKind::GenericArgumentsMismatch: {
1569615703
unsigned impact = 1;
1569715704
if (type1->isMarkerExistential() || type2->isMarkerExistential())
1569815705
++impact;
15706+
15707+
// If generic arguments mismatch ends up being recorded on the result
15708+
// of the chain or a try expression it means that there is a contextual
15709+
// conversion mismatch.
15710+
//
15711+
// For optional conversions the solver currently generates a disjunction
15712+
// with two choices - bind and optional-to-optional conversion which is
15713+
// anchored on the contextual expression. If we can get a fix recorded
15714+
// there that would result in a better diagnostic. It's only possible
15715+
// for optional-to-optional choice because it doesn't bind the
15716+
// variable immediately, so we need to downgrade direct fixes to prevent
15717+
// `bind` choice from considered better.
15718+
if (fix->directlyAt<OptionalEvaluationExpr>() ||
15719+
fix->directlyAt<AnyTryExpr>())
15720+
impact += 2;
15721+
1569915722
return recordFix(fix, impact) ? SolutionKind::Error : SolutionKind::Solved;
1570015723
}
1570115724

@@ -15923,7 +15946,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1592315946
case FixKind::DefaultGenericArgument:
1592415947
case FixKind::AllowMutatingMemberOnRValueBase:
1592515948
case FixKind::AllowTupleSplatForSingleParameter:
15926-
case FixKind::AllowNonClassTypeToConvertToAnyObject:
1592715949
case FixKind::SpecifyClosureParameterType:
1592815950
case FixKind::SpecifyClosureReturnType:
1592915951
case FixKind::AddQualifierToAccessTopLevelName:

test/ClangImporter/MixedSource/mixed-target-using-header.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ func testProtocolNamingConflict() {
6666
let a: ConflictingName1?
6767
var b: ConflictingName1Protocol?
6868
b = a // expected-error {{cannot assign value of type 'ConflictingName1?' to type '(any ConflictingName1Protocol)?'}}
69+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('ConflictingName1' and 'any ConflictingName1Protocol') are expected to be equal}}
6970
_ = b
7071

7172
let c: ConflictingName2?
7273
var d: ConflictingName2Protocol?
7374
d = c // expected-error {{cannot assign value of type 'ConflictingName2?' to type '(any ConflictingName2Protocol)?'}}
75+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('ConflictingName2' and 'any ConflictingName2Protocol') are expected to be equal}}
7476
_ = d
7577
}
7678

test/ClangImporter/cf.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func testOutParametersGood() {
118118
func testOutParametersBad() {
119119
let fridge: CCRefrigerator?
120120
CCRefrigeratorCreateIndirect(fridge) // expected-error {{cannot convert value of type 'CCRefrigerator?' to expected argument type 'UnsafeMutablePointer<CCRefrigerator?>?'}}
121+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('CCRefrigerator' and 'UnsafeMutablePointer<CCRefrigerator?>') are expected to be equal}}
121122

122123
let power: CCPowerSupply?
123124
CCRefrigeratorGetPowerSupplyIndirect(0, power)
@@ -128,21 +129,26 @@ func testOutParametersBad() {
128129
CCRefrigeratorGetItemUnaudited(0, 0, item)
129130
// expected-error@-1:34 {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator'}}
130131
// expected-error@-2:40 {{cannot convert value of type 'CCItem?' to expected argument type 'UnsafeMutablePointer<Unmanaged<CCItem>?>?'}}
132+
// expected-note@-3 {{arguments to generic parameter 'Wrapped' ('CCItem' and 'UnsafeMutablePointer<Unmanaged<CCItem>?>') are expected to be equal}}
131133
}
132134

133135
func nameCollisions() {
134136
var objc: MyProblematicObject?
135137
var cf: MyProblematicObjectRef?
136138
cf = objc // expected-error {{cannot assign value of type 'MyProblematicObject?' to type 'MyProblematicObjectRef?'}}
139+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicObject' and 'MyProblematicObjectRef') are expected to be equal}}
137140
objc = cf // expected-error {{cannot assign value of type 'MyProblematicObjectRef?' to type 'MyProblematicObject?'}}
141+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicObjectRef' and 'MyProblematicObject') are expected to be equal}}
138142

139143
var cfAlias: MyProblematicAliasRef?
140144
cfAlias = cf // okay
141145
cf = cfAlias // okay
142146

143147
var otherAlias: MyProblematicAlias?
144148
otherAlias = cfAlias // expected-error {{cannot assign value of type 'MyProblematicAliasRef?' (aka 'Optional<MyProblematicObjectRef>') to type 'MyProblematicAlias?' (aka 'Optional<Float>')}}
149+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicAliasRef' (aka 'MyProblematicObjectRef') and 'MyProblematicAlias' (aka 'Float')) are expected to be equal}}
145150
cfAlias = otherAlias // expected-error {{cannot assign value of type 'MyProblematicAlias?' (aka 'Optional<Float>') to type 'MyProblematicAliasRef?' (aka 'Optional<MyProblematicObjectRef>')}}
151+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicAlias' (aka 'Float') and 'MyProblematicAliasRef' (aka 'MyProblematicObjectRef')) are expected to be equal}}
146152

147153
func isOptionalFloat(_: inout Optional<Float>) {}
148154
isOptionalFloat(&otherAlias) // okay

test/ClangImporter/ctypes_parse.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ func testFunctionPointers() {
214214

215215
useFunctionPointer2(anotherFP)
216216
sizedFP = fp // expected-error {{cannot assign value of type 'fptr?' (aka 'Optional<@convention(c) (Int32) -> Int32>') to type '(@convention(c) (CInt, CInt, UnsafeMutableRawPointer?) -> Void)?'}}
217+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('fptr' (aka '@convention(c) (Int32) -> Int32') and '@convention(c) (CInt, CInt, UnsafeMutableRawPointer?) -> Void'}}
217218
}
218219

219220
func testStructDefaultInit() {

test/Constraints/bridging-nsnumber-and-nsvalue.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func bridgeNSNumberBackToSpecificType(object: ${ObjectType},
6262
_ = object as? ${Type}
6363
_ = object as! ${Type}
6464

65-
_ = optional as ${Type}? // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
65+
_ = optional as ${Type}? // expected-error{{cannot convert value of type '${ObjectType}?' to type '${Type}?' in coercion}} expected-note {{arguments to generic parameter 'Wrapped' ('${ObjectType}' and '${Type}') are expected to be equal}}
6666
_ = optional is ${Type}?
6767
_ = optional as? ${Type}?
6868
_ = optional as! ${Type}?

test/Constraints/bridging.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,17 @@ func rdar19831698() {
283283
// <rdar://problem/19836341> Incorrect fixit for NSString? to String? conversions
284284
func rdar19836341(_ ns: NSString?, vns: NSString?) {
285285
var vns = vns
286-
let _: String? = ns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{22-22= as String?}}
287-
var _: String? = ns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{22-22= as String?}}
286+
let _: String? = ns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{22-22= as String?}}
287+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
288+
var _: String? = ns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{22-22= as String?}}
289+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
288290

289291
// Important part about below diagnostic is that from-type is described as
290292
// 'NSString?' and not '@lvalue NSString?':
291-
let _: String? = vns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{23-23= as String?}}
292-
var _: String? = vns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{23-23= as String?}}
293+
let _: String? = vns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{23-23= as String?}}
294+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
295+
var _: String? = vns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{23-23= as String?}}
296+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
293297

294298
vns = ns
295299
}
@@ -300,15 +304,17 @@ func rdar20029786(_ ns: NSString?) {
300304
// expected-error@-1 {{cannot convert value of type 'NSString?' to expected argument type 'String?'}} {{21-21= as String?}}
301305
var s2 = ns ?? "str" as String as String // expected-error {{binary operator '??' cannot be applied to operands of type 'NSString?' and 'String'}}
302306

303-
let s3: NSString? = "str" as String? // expected-error {{cannot convert value of type 'String?' to specified type 'NSString?'}}{{39-39= as NSString?}}
307+
let s3: NSString? = "str" as String? // expected-error {{cannot assign value of type 'String?' to type 'NSString?'}}{{39-39= as NSString?}}
308+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('String' and 'NSString') are expected to be equal}}
304309

305310
var s4: String = ns ?? "str" // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{20-20=(}} {{31-31=) as String}}
306311
var s5: String = (ns ?? "str") as String // fixed version
307312
}
308313

309314
// Make sure more complicated cast has correct parenthesization
310315
func castMoreComplicated(anInt: Int?) {
311-
let _: (NSObject & NSCopying)? = anInt // expected-error{{cannot convert value of type 'Int?' to specified type '(any NSObject & NSCopying)?'}}{{41-41= as (any NSObject & NSCopying)?}}
316+
let _: (NSObject & NSCopying)? = anInt // expected-error{{cannot assign value of type 'Int?' to type '(any NSObject & NSCopying)?'}}{{41-41= as (any NSObject & NSCopying)?}}
317+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('Int' and 'any NSObject & NSCopying') are expected to be equal}}
312318
}
313319

314320

test/Constraints/casts_objc.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ func optionalityMismatchingCasts(f: CGFloat, n: NSNumber, fooo: CGFloat???,
8282
nooo: NSNumber???) {
8383
_ = f as NSNumber?
8484
_ = f as NSNumber??
85-
let _ = fooo as NSNumber?? // expected-error{{'CGFloat???' is not convertible to 'NSNumber??'}}
86-
//expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{16-18=as!}}
85+
let _ = fooo as NSNumber?? // expected-error{{cannot convert value of type 'CGFloat???' to type 'NSNumber??' in coercion}}
86+
//expected-note@-1 {{arguments to generic parameter 'Wrapped' ('CGFloat?' and 'NSNumber') are expected to be equal}}
8787
let _ = fooo as NSNumber???? // okay: injects extra optionals
8888
}
8989

test/Constraints/fixes.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,14 @@ struct Q {
158158
let s: String?
159159
}
160160
let q = Q(s: nil)
161-
let a: Int? = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
162-
// expected-error@-1 {{cannot convert value of type 'String.UTF8View?' to specified type 'Int?'}}
163-
// expected-note@-2{{chain the optional using '?'}}{{18-18=?}}
164-
let b: Int = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
161+
let a: Int? = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{18-18=?}}
162+
// expected-error@-1 {{cannot assign value of type 'String.UTF8View?' to type 'Int?'}}
163+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('String.UTF8View' and 'Int') are expected to be equal}}
164+
let b: Int = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{17-17=?}} expected-note {{force-unwrap using '!'}}{{17-17=!}}
165165
// expected-error@-1 {{cannot convert value of type 'String.UTF8View' to specified type 'Int'}}
166-
// expected-note@-2{{chain the optional using '?'}}{{17-17=?}}
167-
// expected-note@-3{{force-unwrap using '!'}}{{17-17=!}}
168-
let d: Int! = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
169-
// expected-error@-1 {{cannot convert value of type 'String.UTF8View?' to specified type 'Int?'}}
170-
// expected-note@-2{{chain the optional using '?'}}{{18-18=?}}
166+
let d: Int! = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{18-18=?}}
167+
// expected-error@-1 {{cannot assign value of type 'String.UTF8View?' to type 'Int?'}}
168+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('String.UTF8View' and 'Int') are expected to be equal}}
171169
let c = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
172170
// expected-note@-1{{chain the optional using '?' to access member 'utf8' only for non-'nil' base values}}{{12-12=?}}
173171
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}{{12-12=!}}

test/Constraints/invalid_implicit_conversions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func test(
2929

3030
takesAutoclosure(rawPtr, a) // expected-error {{cannot perform pointer conversion of value of type '[Int]' to autoclosure result type 'UnsafeRawPointer'}}
3131
takesAutoclosure(ptr, a) // expected-error {{cannot perform pointer conversion of value of type '[Int]' to autoclosure result type 'UnsafePointer<Int>'}}
32-
takesAutoclosure(optPtr, b) // expected-error {{cannot perform pointer conversion of value of type '[Int]?' to autoclosure result type 'UnsafePointer<Int>?'}}
32+
takesAutoclosure(optPtr, b) // expected-error {{conflicting arguments to generic parameter 'T' ('UnsafePointer<Int>?' vs. '[Int]?')}}
3333

3434
takesAutoclosure(rawPtr, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafeRawPointer'}}
3535
takesAutoclosure(ptrI8, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafePointer<Int8>'}}

test/Constraints/issue-81023.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// https://github.com/swiftlang/swift/issues/81023
4+
5+
protocol MyPublisher {
6+
associatedtype Output
7+
associatedtype Failure: Error
8+
func eraseToAnyPublisher() -> MyAnyPublisher<Output, Failure>
9+
}
10+
11+
extension MyPublisher {
12+
func eraseToAnyPublisher() -> MyAnyPublisher<Output, Failure> {
13+
fatalError()
14+
}
15+
}
16+
17+
struct MyAnyPublisher<Output, Failure: Error>: MyPublisher {}
18+
struct MyJust<Output>: MyPublisher {
19+
typealias Failure = Never
20+
init(_ value: Output) {}
21+
}
22+
23+
extension MyPublisher where Output == (any Collection)? { // expected-note {{where 'Self.Output' = '[Int]?'}}
24+
func mapCount() -> MyAnyPublisher<Int, Failure> { fatalError() }
25+
}
26+
27+
func test(myPub: MyAnyPublisher<[Int]?, Never>) {
28+
myPub.mapCount()
29+
// expected-error@-1 {{referencing instance method 'mapCount()' on 'MyPublisher' requires the types '[Int]?' and '(any Collection)?' be equivalent}}
30+
}

test/Constraints/iuo.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ let _ = (returnsIUO as () -> Int)() // expected-error {{cannot convert value of
216216
// Make sure we only permit an IUO unwrap on the first application.
217217
func returnsIUOFn() -> (() -> Int?)! { nil }
218218
let _: (() -> Int?)? = returnsIUOFn()
219-
let _: (() -> Int)? = returnsIUOFn() // expected-error {{cannot convert value of type '(() -> Int?)?' to specified type '(() -> Int)?'}}
219+
let _: (() -> Int)? = returnsIUOFn() // expected-error {{cannot assign value of type '(() -> Int?)?' to type '(() -> Int)?'}}
220+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('() -> Int?' and '() -> Int') are expected to be equal}}
220221
let _: () -> Int? = returnsIUOFn()
221222
let _: () -> Int = returnsIUOFn() // expected-error {{cannot convert value of type '(() -> Int?)?' to specified type '() -> Int'}}
222223
let _: Int? = returnsIUOFn()()

test/Constraints/keypath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Demo {
3434

3535
let some = Some(keyPath: \Demo.here)
3636
// expected-error@-1 {{cannot convert value of type 'KeyPath<Demo, (() -> Void)?>' to expected argument type 'KeyPath<Demo, ((V) -> Void)?>'}}
37-
// expected-note@-2 {{arguments to generic parameter 'Value' ('(() -> Void)?' and '((V) -> Void)?') are expected to be equal}}
37+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('() -> Void' and '(V) -> Void') are expected to be equal}}
3838
// expected-error@-3 {{generic parameter 'V' could not be inferred}}
3939
// expected-note@-4 {{explicitly specify the generic arguments to fix this issue}}
4040

test/Constraints/operator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ func rdar60727310() {
278278
func myAssertion<T>(_ a: T, _ op: ((T,T)->Bool), _ b: T) {}
279279
var e: Error? = nil
280280
myAssertion(e, ==, nil) // expected-error {{cannot convert value of type '(any Error)?' to expected argument type '(any (~Copyable & ~Escapable).Type)?'}}
281+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('any Error' and 'any (~Copyable & ~Escapable).Type') are expected to be equal}}
281282
}
282283

283284
// https://github.com/apple/swift/issues/54877

test/Constraints/subscript.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ let squares = [ 1, 2, 3 ].reduce([:]) { (dict, n) in
113113
func r23670252(_ dictionary: [String : AnyObject], someObject: AnyObject) {
114114
let color : String?
115115
color = dictionary["color"] // expected-error {{cannot assign value of type 'AnyObject?' to type 'String?'}}
116+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('AnyObject' and 'String') are expected to be equal}}
116117
_ = color
117118
}
118119

0 commit comments

Comments
 (0)