diff --git a/Sources/Nimble/Matchers/BeIdenticalTo.swift b/Sources/Nimble/Matchers/BeIdenticalTo.swift index 3f00b187f..85e5b50c8 100644 --- a/Sources/Nimble/Matchers/BeIdenticalTo.swift +++ b/Sources/Nimble/Matchers/BeIdenticalTo.swift @@ -1,6 +1,6 @@ /// A Nimble matcher that succeeds when the actual value is the same instance /// as the expected instance. -public func beIdenticalTo(_ expected: AnyObject?) -> Matcher { +public func beIdenticalTo(_ expected: T?) -> Matcher { return Matcher.define { actualExpression in let actual = try actualExpression.evaluate() @@ -35,7 +35,7 @@ public func !== (lhs: AsyncExpectation, rhs: AnyObject?) async { /// as the expected instance. /// /// Alias for "beIdenticalTo". -public func be(_ expected: AnyObject?) -> Matcher { +public func be(_ expected: T?) -> Matcher { return beIdenticalTo(expected) } diff --git a/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift b/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift index a82077b2e..0ba2316d0 100644 --- a/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift +++ b/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift @@ -12,6 +12,8 @@ final class BeIdenticalToObjectTest: XCTestCase { func testBeIdenticalToPositive() { expect(self.testObjectA).to(beIdenticalTo(testObjectA)) + // check that the typing works out when used as a submatcher. + expect(self.testObjectA).to(map({ $0 }, beIdenticalTo(testObjectA))) } func testBeIdenticalToNegative() {