mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
//===--- ConstraintSimplificationTests.cpp --------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "SemaFixture.h"
|
|
#include "swift/Sema/ConstraintSystem.h"
|
|
|
|
using namespace swift;
|
|
using namespace swift::unittest;
|
|
using namespace swift::constraints;
|
|
|
|
TEST_F(SemaTest, TestTrailingClosureMatchRecordingForIdenticalFunctions) {
|
|
ConstraintSystem cs(DC, ConstraintSystemOptions());
|
|
|
|
auto intType = getStdlibType("Int");
|
|
auto floatType = getStdlibType("Float");
|
|
|
|
auto func = FunctionType::get({FunctionType::Param(intType)}, floatType);
|
|
|
|
cs.addConstraint(
|
|
ConstraintKind::ApplicableFunction, func, func,
|
|
cs.getConstraintLocator({}, ConstraintLocator::ApplyFunction));
|
|
|
|
SmallVector<Solution, 2> solutions;
|
|
cs.solve(solutions);
|
|
|
|
ASSERT_EQ(solutions.size(), (unsigned)1);
|
|
|
|
const auto &solution = solutions.front();
|
|
|
|
auto *locator = cs.getConstraintLocator({}, ConstraintLocator::ApplyArgument);
|
|
auto choice = solution.trailingClosureMatchingChoices.find(locator);
|
|
ASSERT_TRUE(choice != solution.trailingClosureMatchingChoices.end());
|
|
ASSERT_EQ(choice->second, TrailingClosureMatching::Forward);
|
|
}
|