Skip to content

Commit 8d142ee

Browse files
authored
Merge pull request swiftlang#22719 from xedin/rdar-48114578
[CSApply] Account for failures in argument application of unresolved …
2 parents 7ea8768 + 875932b commit 8d142ee

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2444,8 +2444,16 @@ namespace {
24442444
expr->getArgumentLabelLocs(), expr->hasTrailingClosure(),
24452445
/*implicit=*/expr->isImplicit(), Type(), getType);
24462446
result = finishApply(apply, Type(), cs.getConstraintLocator(expr));
2447+
2448+
// FIXME: Application could fail, because some of the solutions
2449+
// are not expressible in AST (yet?), like certain tuple-to-tuple
2450+
// conversions. Better solution here would be not to form solutions
2451+
// which couldn't be applied by e.g. detecting situations like that
2452+
// and inserting fixes early.
2453+
if (!result)
2454+
return nullptr;
24472455
}
2448-
2456+
24492457
// Check for ambiguous member if the base is an Optional
24502458
if (baseTy->getOptionalObjectType()) {
24512459
diagnoseAmbiguousNominalMember(baseTy, result);

test/Constraints/members.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,25 @@ func rdar46211109() {
517517
let _: MyIntSequenceStruct? = foo(Int.Self)
518518
// expected-error@-1 {{type 'Int' has no member 'Self'}}
519519
}
520+
521+
func rdar_48114578() {
522+
struct S<T> {
523+
var value: T
524+
525+
static func valueOf<T>(_ v: T) -> S<T> {
526+
return S<T>(value: v)
527+
}
528+
}
529+
530+
typealias A = (a: [String]?, b: Int)
531+
532+
func foo(_ a: [String], _ b: Int) -> S<A> {
533+
let v = (a, b)
534+
return .valueOf(v)
535+
// expected-error@-1 {{cannot express tuple conversion '([String], Int)' to '(a: [String]?, b: Int)'}}
536+
}
537+
538+
func bar(_ a: [String], _ b: Int) -> S<A> {
539+
return .valueOf((a, b)) // Ok
540+
}
541+
}

0 commit comments

Comments
 (0)