Skip to content

Commit 46d14cf

Browse files
committed
[unittest] NFC: Adjust Sema unit tests to check result of generateConstraints
1 parent 48e70ed commit 46d14cf

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

unittests/Sema/PlaceholderTypeInferenceTests.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ TEST_F(SemaTest, TestPlaceholderInferenceForArrayLiteral) {
3636

3737
ConstraintSystem cs(DC, ConstraintSystemOptions());
3838
cs.setContextualType(arrayExpr, {arrayRepr, arrayTy}, CTP_Initialization);
39-
cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
39+
auto failed = cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
40+
ASSERT_FALSE(failed);
41+
4042
SmallVector<Solution, 2> solutions;
4143
cs.solve(solutions);
4244

@@ -75,7 +77,9 @@ TEST_F(SemaTest, TestPlaceholderInferenceForDictionaryLiteral) {
7577

7678
ConstraintSystem cs(DC, ConstraintSystemOptions());
7779
cs.setContextualType(dictExpr, {dictRepr, dictTy}, CTP_Initialization);
78-
cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
80+
auto failed = cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
81+
ASSERT_FALSE(failed);
82+
7983
SmallVector<Solution, 2> solutions;
8084
cs.solve(solutions);
8185

unittests/Sema/UnresolvedMemberLookupTests.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ TEST_F(SemaTest, TestLookupAlwaysLooksThroughOptionalBase) {
3333
auto *UMCRE = new (Context) UnresolvedMemberChainResultExpr(UME, UME);
3434

3535
ConstraintSystem cs(DC, ConstraintSystemOptions());
36-
cs.generateConstraints(UMCRE, DC);
36+
auto *expr = cs.generateConstraints(UMCRE, DC);
37+
ASSERT_TRUE(expr);
38+
3739
cs.addConstraint(
38-
ConstraintKind::Conversion, cs.getType(UMCRE), intOptType,
40+
ConstraintKind::Conversion, cs.getType(expr), intOptType,
3941
cs.getConstraintLocator(UMCRE, ConstraintLocator::ContextualType));
4042
SmallVector<Solution, 2> solutions;
4143
cs.solve(solutions);
@@ -67,10 +69,12 @@ TEST_F(SemaTest, TestLookupPrefersResultsOnOptionalRatherThanBase) {
6769
auto *UMCRE = new (Context) UnresolvedMemberChainResultExpr(UME, UME);
6870

6971
ConstraintSystem cs(DC, ConstraintSystemOptions());
70-
cs.generateConstraints(UMCRE, DC);
72+
auto *expr = cs.generateConstraints(UMCRE, DC);
73+
ASSERT_TRUE(expr);
74+
7175
cs.addConstraint(
72-
ConstraintKind::Conversion, cs.getType(UMCRE), intOptType,
73-
cs.getConstraintLocator(UMCRE, ConstraintLocator::ContextualType));
76+
ConstraintKind::Conversion, cs.getType(expr), intOptType,
77+
cs.getConstraintLocator(expr, ConstraintLocator::ContextualType));
7478
SmallVector<Solution, 2> solutions;
7579
cs.solve(solutions);
7680

0 commit comments

Comments
 (0)