Skip to content

Commit

Permalink
Only need to filter platforms when materialization is not strict
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Jul 30, 2022
1 parent 087e3e4 commit 9d878cb
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions bundler/lib/bundler/lazy_specification.rb
Expand Up @@ -89,21 +89,19 @@ def materialize_for_resolution

def __materialize__(platform)
@specification = begin
search_object = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?
Dependency.new(name, version)
candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?
source.specs.search(Dependency.new(name, version)).select do |spec|
MatchPlatform.platforms_match?(spec.platform, platform)
end
else
self
source.specs.search(self)
end
candidates = source.specs.search(search_object)
same_platform_candidates = candidates.select do |spec|
MatchPlatform.platforms_match?(spec.platform, platform)
end
installable_candidates = same_platform_candidates.select do |spec|
installable_candidates = candidates.select do |spec|
spec.is_a?(StubSpecification) ||
(spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
end
search = installable_candidates.last || same_platform_candidates.last
search = installable_candidates.last || candidates.last
search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
search
end
Expand Down

0 comments on commit 9d878cb

Please sign in to comment.