Skip to content

Commit 2e1609e

Browse files
[tests] Adjusting SR-12869 test cases for optional mismatches
1 parent 086ad33 commit 2e1609e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3367,8 +3367,7 @@ bool ConstraintSystem::repairFailures(
33673367
conversionsOrFixes.push_back(
33683368
IgnoreAssignmentDestinationType::create(*this, lhs, rhs, loc));
33693369
} else {
3370-
conversionsOrFixes.push_back(
3371-
TreatRValueAsLValue::create(*this, loc));
3370+
conversionsOrFixes.push_back(TreatRValueAsLValue::create(*this, loc));
33723371
}
33733372

33743373
return true;
@@ -8876,11 +8875,11 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
88768875
// tuple mismatch.
88778876
if (hasFixFor(loc, FixKind::AllowTupleTypeMismatch))
88788877
return true;
8879-
8878+
88808879
if (restriction == ConversionRestrictionKind::ValueToOptional ||
88818880
restriction == ConversionRestrictionKind::OptionalToOptional)
88828881
++impact;
8883-
8882+
88848883
auto *fix =
88858884
loc->isLastElement<LocatorPathElt::ApplyArgToParam>()
88868885
? AllowArgumentMismatch::create(*this, fromType, toType, loc)

test/Constraints/tuple.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,15 @@ let _ = dupLabelSubscriptStruct[foo: 5, foo: 5] // ok
323323

324324
var dict: [String: (Int, Int)] = [:]
325325
let bignum: Int64 = 1337
326-
dict["test"] = (bignum, 1) // expected-error {{cannot assign value of type '(Int64, Int)' to type '(Int, Int)'}}
327-
// expected-error@-1 {{cannot assign value of type '(Int64, Int)' to subscript of type '(Int, Int)'}}
326+
dict["test"] = (bignum, 1) // expected-error {{cannot assign value of type '(Int64, Int)' to subscript of type '(Int, Int)'}}
328327

329328
var tuple: (Int, Int)
330329
tuple = (bignum, 1) // expected-error {{cannot assign value of type '(Int64, Int)' to type '(Int, Int)'}}
330+
331+
var optionalTuple: (Int, Int)?
332+
var optionalTuple2: (Int64, Int)? = (bignum, 1)
333+
var optionalTuple3: (UInt64, Int)? = (bignum, 1) // expected-error {{cannot convert value of type '(Int64, Int)' to specified type '(UInt64, Int)?'}}
334+
335+
optionalTuple = (bignum, 1) // expected-error {{cannot assign value of type '(Int64, Int)' to type '(Int, Int)'}}
336+
// Optional to Optional
337+
optionalTuple = optionalTuple2 // expected-error {{cannot assign value of type '(Int64, Int)?' to type '(Int, Int)?'}}

0 commit comments

Comments
 (0)