diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionMetadata.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionMetadata.java index fde1c8fcd6887c..d680b3100402c3 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionMetadata.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionMetadata.java @@ -188,7 +188,7 @@ private static Optional generateFixupMessage( .collect(toImmutableSet()); var actualImports = rootUsages.stream() - .flatMap(usage -> usage.getImports().keySet().stream()) + .flatMap(usage -> usage.getImports().values().stream()) .filter(repo -> !actualDevImports.contains(repo)) .collect(toImmutableSet()); diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java index a51d03c9da55da..13902ae832ae10 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java @@ -1603,13 +1603,23 @@ public void extensionMetadata() throws Exception { "bazel_dep(name='ext', version='1.0')", "bazel_dep(name='data_repo',version='1.0')", "ext = use_extension('@ext//:defs.bzl', 'ext')", - "use_repo(ext, 'direct_dep', 'indirect_dep', 'invalid_dep')", + "use_repo(", + " ext,", + " 'indirect_dep',", + " 'invalid_dep',", + " my_direct_dep = 'direct_dep',", + ")", "ext_dev = use_extension('@ext//:defs.bzl', 'ext', dev_dependency = True)", - "use_repo(ext_dev, 'direct_dev_dep', 'indirect_dev_dep', 'invalid_dev_dep')"); + "use_repo(", + " ext_dev,", + " 'indirect_dev_dep',", + " 'invalid_dev_dep',", + " my_direct_dev_dep = 'direct_dev_dep',", + ")"); scratch.file(workspaceRoot.getRelative("BUILD").getPathString()); scratch.file( workspaceRoot.getRelative("data.bzl").getPathString(), - "load('@direct_dep//:data.bzl', direct_dep_data='data')", + "load('@my_direct_dep//:data.bzl', direct_dep_data='data')", "data = direct_dep_data"); registry.addModule(