Skip to content

Commit

Permalink
Remove resolve_call_path_and_mod_path.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Oct 26, 2024
1 parent ec5c82d commit 15af0d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
11 changes: 6 additions & 5 deletions sway-core/src/semantic_analysis/type_check_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use sway_types::{span::Span, Ident, Spanned};
use super::{
symbol_collection_context::SymbolCollectionContext,
type_resolve::{
resolve_call_path, resolve_call_path_and_mod_path, resolve_qualified_call_path,
resolve_symbol_and_mod_path, resolve_type, VisibilityCheck,
resolve_call_path, resolve_qualified_call_path, resolve_symbol_and_mod_path, resolve_type,
VisibilityCheck,
},
GenericShadowingMode,
};
Expand Down Expand Up @@ -736,15 +736,16 @@ impl<'a> TypeCheckContext<'a> {
handler: &Handler,
call_path: &CallPath,
) -> Result<ty::TyDecl, ErrorEmitted> {
resolve_call_path_and_mod_path(
resolve_call_path(
handler,
self.engines(),
self.namespace().root_module(),
self.namespace(),
self.namespace().mod_path(),
call_path,
self.self_type(),
VisibilityCheck::No,
)
.map(|d| d.0.expect_typed())
.map(|d| d.expect_typed())
}

/// Given a name and a type (plus a `self_type` to potentially
Expand Down
33 changes: 8 additions & 25 deletions sway-core/src/semantic_analysis/type_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
CallPath, QualifiedCallPath,
},
monomorphization::type_decl_opt_to_type_id,
namespace::{Module, ModulePath, ModulePathBuf, ResolvedDeclaration, ResolvedTraitImplItem},
namespace::{Module, ModulePath, ResolvedDeclaration, ResolvedTraitImplItem},
type_system::SubstTypes,
EnforceTypeArguments, Engines, Namespace, SubstTypesContext, TypeId, TypeInfo,
};
Expand Down Expand Up @@ -318,44 +318,27 @@ pub fn resolve_qualified_call_path(
/// The `mod_path` is significant here as we assume the resolution is done within the
/// context of the module pointed to by `mod_path` and will only check the call path prefixes
/// and the symbol's own visibility.
pub fn resolve_call_path_and_mod_path(
pub fn resolve_call_path(
handler: &Handler,
engines: &Engines,
module: &Module,
namespace: &Namespace,
mod_path: &ModulePath,
call_path: &CallPath,
self_type: Option<TypeId>,
) -> Result<(ResolvedDeclaration, ModulePathBuf), ErrorEmitted> {
check_visibility: VisibilityCheck,
) -> Result<ResolvedDeclaration, ErrorEmitted> {
let symbol_path: Vec<_> = mod_path
.iter()
.chain(&call_path.prefixes)
.cloned()
.collect();
resolve_symbol_and_mod_path(
handler,
engines,
module,
&symbol_path,
&call_path.suffix,
self_type,
)
}

pub fn resolve_call_path(
handler: &Handler,
engines: &Engines,
namespace: &Namespace,
mod_path: &ModulePath,
call_path: &CallPath,
self_type: Option<TypeId>,
check_visibility: VisibilityCheck,
) -> Result<ResolvedDeclaration, ErrorEmitted> {
let (decl, mod_path) = resolve_call_path_and_mod_path(
let (decl, mod_path) = resolve_symbol_and_mod_path(
handler,
engines,
namespace.root_module(),
mod_path,
call_path,
&symbol_path,
&call_path.suffix,
self_type,
)?;

Expand Down

0 comments on commit 15af0d1

Please sign in to comment.