@@ -51,22 +51,6 @@ public struct Term<Identifier: PackageContainerIdentifier>: Equatable, Hashable
5151 return self . relation ( with: other) == . subset
5252 }
5353
54- func isSatisfied( by other: Version ) -> Bool {
55- let isSatisfied : Bool
56- switch requirement {
57- case . versionSet( . exact( let version) ) :
58- isSatisfied = version == other
59- case . versionSet( . range( let range) ) :
60- isSatisfied = range. contains ( version: other)
61- case . versionSet( . any) :
62- isSatisfied = true
63- default :
64- isSatisfied = false
65- }
66-
67- return isPositive ? isSatisfied : !isSatisfied
68- }
69-
7054 /// Create an intersection with another term.
7155 func intersect( with other: Term ) -> Term ? {
7256 guard self . package == other. package else { return nil }
@@ -1296,8 +1280,16 @@ public final class PubgrubDependencyResolver<
12961280 func getBestAvailableVersion( for term: Term < Identifier > ) throws -> Version ? {
12971281 assert ( term. isPositive, " Expected term to be positive " )
12981282 let container = try getContainer ( for: term. package )
1299- let availableVersions = container. versions ( filter: { term. isSatisfied ( by: $0) } )
1300- return availableVersions. first { _ in true }
1283+
1284+ switch term. requirement {
1285+ case . versionSet( let versionSet) :
1286+ let availableVersions = container. versions ( filter: { versionSet. contains ( $0) } )
1287+ return availableVersions. first { _ in true }
1288+ case . revision:
1289+ fatalError ( )
1290+ case . unversioned:
1291+ fatalError ( )
1292+ }
13011293 }
13021294
13031295 /// Returns the incompatibilities of a package at the given version.
0 commit comments