mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[unittest] NFC: Adjust Sema unit tests to check result of generateConstraints
This commit is contained in:
@@ -36,7 +36,9 @@ TEST_F(SemaTest, TestPlaceholderInferenceForArrayLiteral) {
|
||||
|
||||
ConstraintSystem cs(DC, ConstraintSystemOptions());
|
||||
cs.setContextualType(arrayExpr, {arrayRepr, arrayTy}, CTP_Initialization);
|
||||
cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
|
||||
auto failed = cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
|
||||
ASSERT_FALSE(failed);
|
||||
|
||||
SmallVector<Solution, 2> solutions;
|
||||
cs.solve(solutions);
|
||||
|
||||
@@ -75,7 +77,9 @@ TEST_F(SemaTest, TestPlaceholderInferenceForDictionaryLiteral) {
|
||||
|
||||
ConstraintSystem cs(DC, ConstraintSystemOptions());
|
||||
cs.setContextualType(dictExpr, {dictRepr, dictTy}, CTP_Initialization);
|
||||
cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
|
||||
auto failed = cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
|
||||
ASSERT_FALSE(failed);
|
||||
|
||||
SmallVector<Solution, 2> solutions;
|
||||
cs.solve(solutions);
|
||||
|
||||
|
||||
@@ -33,9 +33,11 @@ TEST_F(SemaTest, TestLookupAlwaysLooksThroughOptionalBase) {
|
||||
auto *UMCRE = new (Context) UnresolvedMemberChainResultExpr(UME, UME);
|
||||
|
||||
ConstraintSystem cs(DC, ConstraintSystemOptions());
|
||||
cs.generateConstraints(UMCRE, DC);
|
||||
auto *expr = cs.generateConstraints(UMCRE, DC);
|
||||
ASSERT_TRUE(expr);
|
||||
|
||||
cs.addConstraint(
|
||||
ConstraintKind::Conversion, cs.getType(UMCRE), intOptType,
|
||||
ConstraintKind::Conversion, cs.getType(expr), intOptType,
|
||||
cs.getConstraintLocator(UMCRE, ConstraintLocator::ContextualType));
|
||||
SmallVector<Solution, 2> solutions;
|
||||
cs.solve(solutions);
|
||||
@@ -67,10 +69,12 @@ TEST_F(SemaTest, TestLookupPrefersResultsOnOptionalRatherThanBase) {
|
||||
auto *UMCRE = new (Context) UnresolvedMemberChainResultExpr(UME, UME);
|
||||
|
||||
ConstraintSystem cs(DC, ConstraintSystemOptions());
|
||||
cs.generateConstraints(UMCRE, DC);
|
||||
auto *expr = cs.generateConstraints(UMCRE, DC);
|
||||
ASSERT_TRUE(expr);
|
||||
|
||||
cs.addConstraint(
|
||||
ConstraintKind::Conversion, cs.getType(UMCRE), intOptType,
|
||||
cs.getConstraintLocator(UMCRE, ConstraintLocator::ContextualType));
|
||||
ConstraintKind::Conversion, cs.getType(expr), intOptType,
|
||||
cs.getConstraintLocator(expr, ConstraintLocator::ContextualType));
|
||||
SmallVector<Solution, 2> solutions;
|
||||
cs.solve(solutions);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user