for (Versioned candidate : sortLatestFirst(versions)) {
<BUG>ModuleComponentIdentifier candidateIdentifier = DefaultModuleComponentIdentifier.newId(requested.getGroup(), requested.getName(), candidate.getVersion());
</BUG>
MetadataProvider metadataProvider = new MetadataProvider(new MetaDataSupplier(dependency, candidateIdentifier, moduleAccess));
<BUG>if (versionMatches(requested, candidateIdentifier, metadataProvider)) {
</BUG>
if (!isRejectedByRules(candidateIdentifier, rules, metadataProvider)) {
return candidateIdentifier;
}
<BUG>if (versionMatcher.matchesUniqueVersion(requested.getVersion())) {
break;</BUG>
}

for (Versioned candidate : sortLatestFirst(versions)) {
ModuleComponentIdentifier candidateIdentifier = DefaultModuleComponentIdentifier.newId(requestedModule.getGroup(), requestedModule.getName(), candidate.getVersion());
MetadataProvider metadataProvider = new MetadataProvider(new MetaDataSupplier(dependency, candidateIdentifier, moduleAccess));
if (versionMatches(requestedVersion, candidateIdentifier, metadataProvider)) {
if (!isRejectedByRules(candidateIdentifier, rules, metadataProvider)) {
return candidateIdentifier;
