Skip to content

Commit

Permalink
Force loading from cache before asking ensureParsed
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed May 11, 2023
1 parent 0f82e6a commit 67cf459
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ImportResolver(compiler: Compiler) {
] =
ir.imports.map {
case imp: IR.Module.Scope.Import.Module =>
tryResolveImport(ir, imp)
tryResolveImport(ir, imp, bindingsCachingEnabled)
case other => (other, None)
}
currentLocal.resolvedImports = importedModules.flatMap(_._2)
Expand Down Expand Up @@ -100,6 +100,7 @@ class ImportResolver(compiler: Compiler) {
concreteBindings
}
current.bindings = converted.getOrElse(null)
current.bindings = converted.getOrElse(null)
(
converted
.map(
Expand Down Expand Up @@ -133,11 +134,13 @@ class ImportResolver(compiler: Compiler) {
}

private def tryResolveAsType(
name: IR.Name.Qualified
name: IR.Name.Qualified,
bindingsCachingEnabled: Boolean
): Option[ResolvedType] = {
val tp = name.parts.last.name
val mod = name.parts.dropRight(1).map(_.name).mkString(".")
compiler.getModule(mod).flatMap { mod =>
mapImports(mod, bindingsCachingEnabled)
compiler.ensureParsed(mod)
mod.getIr
.unsafeGetMetadata(
Expand All @@ -154,7 +157,8 @@ class ImportResolver(compiler: Compiler) {

private def tryResolveImport(
module: IR.Module,
imp: Import.Module
imp: Import.Module,
bindingsCachingEnabled: Boolean
): (IR.Module.Scope.Import, Option[BindingsMap.ResolvedImport]) = {
val impName = imp.name.name
val exp = module.exports
Expand Down Expand Up @@ -242,7 +246,7 @@ class ImportResolver(compiler: Compiler) {
)
)
case None =>
tryResolveAsType(imp.name) match {
tryResolveAsType(imp.name, bindingsCachingEnabled) match {
case Some(tp) =>
(imp, Some(BindingsMap.ResolvedImport(imp, exp, tp)))
case None =>
Expand Down

0 comments on commit 67cf459

Please sign in to comment.