Skip to content

Commit

Permalink
fix build failure surfacing as
Browse files Browse the repository at this point in the history
  _ cannot be resolved. It is indirectly referenced _

+ avoid singleton SplitPackageBinding
+ don't loop over array of non-unique modules
+ assert (if -ea is set) that plain package has no split child
  • Loading branch information
stephan-herrmann committed Jul 20, 2024
1 parent 4f65896 commit 8d73547
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ private PackageBinding computePackageFrom(char[][] constantPoolName, boolean isM
if (this.useModuleSystem) {
if (this.module.isUnnamed()) {
char[][] currentCompoundName = CharOperation.arrayConcat(parent.compoundName, constantPoolName[i]);
char[][] declaringModules = ((IModuleAwareNameEnvironment) this.nameEnvironment).getModulesDeclaringPackage(
char[][] declaringModules = ((IModuleAwareNameEnvironment) this.nameEnvironment).getUniqueModulesDeclaringPackage(
currentCompoundName, ModuleBinding.ANY);
List<PackageBinding> bindings = new ArrayList<>();
if (declaringModules != null) {
Expand Down Expand Up @@ -2403,7 +2403,7 @@ public Binding getInaccessibleBinding(char[][] compoundName, ModuleBinding clien
int length = compoundName.length;
for (int j=length; j>0; j--) {
char[][] candidateName = CharOperation.subarray(compoundName, 0, j);
char[][] moduleNames = moduleEnv.getModulesDeclaringPackage(candidateName, ModuleBinding.ANY);
char[][] moduleNames = moduleEnv.getUniqueModulesDeclaringPackage(candidateName, ModuleBinding.ANY);
if (moduleNames != null) {
// in some module a package named candidateName exists, verify observability & inaccessibility:
PackageBinding inaccessiblePackage = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 GK Software SE, and others.
* Copyright (c) 2019, 2024 GK Software SE, and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -44,4 +44,10 @@ public PlainPackageBinding getIncarnation(ModuleBinding moduleBinding) {
return this;
return null;
}

@Override
PackageBinding addPackage(PackageBinding element, ModuleBinding module) {
assert element instanceof PlainPackageBinding : "PlainPackageBinding cannot be parent of split " + element; //$NON-NLS-1$
return super.addPackage(element, module);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public static PackageBinding combineAll(List<PackageBinding> bindings, ModuleBin
split.add(packageBinding);
}
}
if (split.incarnations.size() == 1) // we don't want singleton SplitPackageBinding
return split.incarnations.iterator().next(); // simply peel the only incarnation
return split;
}
}
Expand Down

0 comments on commit 8d73547

Please sign in to comment.