From fed7ceb739f35f926ae04f818f37b851af1f0f65 Mon Sep 17 00:00:00 2001 From: Yim Lee Date: Mon, 27 Mar 2023 21:02:28 -0700 Subject: [PATCH] Fix compilation error in Swift 5.7.2 Motivation: ``` Sources/PackageGraph/PackageGraph+Loading.swift:535:16: error: type 'Pair' does not conform to protocol 'Equatable' struct Pair: Hashable { ``` Modification: Move `Pair` out of `createResolvedPackages` method and it seems happy. --- .../PackageGraph/PackageGraph+Loading.swift | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Sources/PackageGraph/PackageGraph+Loading.swift b/Sources/PackageGraph/PackageGraph+Loading.swift index 838100fd77c..170270c7c29 100644 --- a/Sources/PackageGraph/PackageGraph+Loading.swift +++ b/Sources/PackageGraph/PackageGraph+Loading.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift open source project // -// Copyright (c) 2014-2021 Apple Inc. and the Swift project authors +// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information @@ -532,21 +532,6 @@ private func createResolvedPackages( } } - struct Pair: Hashable { - let package1: Package - let package2: Package - - static func == (lhs: Pair, rhs: Pair) -> Bool { - return lhs.package1.identity == rhs.package1.identity && - lhs.package2.identity == rhs.package2.identity - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(self.package1.identity) - hasher.combine(self.package2.identity) - } - } - var potentiallyDuplicatePackages = [Pair: [String]]() for entry in duplicateTargets { // the duplicate is across exactly two packages @@ -605,6 +590,21 @@ private func createResolvedPackages( return try packageBuilders.map{ try $0.construct() } } +fileprivate struct Pair: Hashable { + let package1: Package + let package2: Package + + static func == (lhs: Pair, rhs: Pair) -> Bool { + return lhs.package1.identity == rhs.package1.identity && + lhs.package2.identity == rhs.package2.identity + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(self.package1.identity) + hasher.combine(self.package2.identity) + } +} + fileprivate extension Product { var isDefaultLibrary: Bool { return type == .library(.automatic)