Skip to content

Commit

Permalink
Request definedEntities for Import
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Mar 27, 2024
1 parent 212e270 commit c54b8cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected ImportResolverAlgorithm() {}
*/
protected abstract java.util.List<String> hiddenNames(Export ex);

protected abstract java.util.List<ResolvedType> definedEntities(String name);
protected abstract java.util.List<ResolvedType> definedEntities(Import name);

/**
* Ensure library is loaded and load a module.
Expand Down Expand Up @@ -153,11 +153,11 @@ private ResolvedType tryResolveAsTypeNew(Import name) {
var last = parts.size() - 1;
var tp = parts.get(last);
var modName = String.join(".", parts.subList(0, last).stream().toList());
var entities = definedEntities(modName);
var entities = definedEntities(name);
if (entities == null) {
return null;
}
var type = definedEntities(modName).stream().filter(e -> nameForType(e).equals(tp)).findFirst();
var type = entities.stream().filter(e -> nameForType(e).equals(tp)).findFirst();
return type.orElse(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.enso.compiler.Compiler;
import org.enso.compiler.context.CompilerContext;
import org.enso.compiler.core.ir.Module;
import org.enso.compiler.core.ir.Name;
import org.enso.compiler.core.ir.expression.errors.ImportExport;
import org.enso.compiler.core.ir.module.scope.Export;
import org.enso.compiler.core.ir.module.scope.Import;
Expand Down Expand Up @@ -84,9 +83,12 @@ protected final java.util.List<String> hiddenNames(Export.Module ex) {
}

@Override
protected final java.util.List<BindingsMap.ResolvedType> definedEntities(String name) {
protected final java.util.List<BindingsMap.ResolvedType> definedEntities(Import.Module name) {
var parts = partsForImport(name);
var last = parts.size() - 1;
var modName = String.join(".", parts.subList(0, last).stream().toList());
var compiler = this.getCompiler();
var optionMod = compiler.getModule(name);
var optionMod = compiler.getModule(modName);
if (optionMod.isEmpty()) {
return null;
}
Expand Down

0 comments on commit c54b8cd

Please sign in to comment.