Skip to content

Commit

Permalink
dsdsa
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Aug 19, 2024
1 parent d552ee0 commit 367d81b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 36 deletions.
31 changes: 13 additions & 18 deletions sway-core/src/semantic_analysis/symbol_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,8 @@ impl ResolveSymbols for Expression {
ExpressionKind::Literal(_) => {}
ExpressionKind::AmbiguousPathExpression(_) => {}
ExpressionKind::FunctionApplication(expr) => {
let result = SymbolResolveTypeBinding::resolve_symbol(
&mut expr.call_path_binding,
&Handler::default(),
ctx.by_ref(),
);
let result = expr.call_path_binding.resolve_symbol(handler, ctx.by_ref());

if let Ok(result) = result {
expr.resolved_call_path_binding = Some(TypeBinding::<
ResolvedCallPath<ParsedDeclId<FunctionDeclaration>>,
Expand Down Expand Up @@ -541,13 +538,11 @@ impl ResolveSymbols for Expression {
.iter_mut()
.for_each(|e| e.resolve_symbols(handler, ctx.by_ref())),
ExpressionKind::Struct(expr) => {
expr.call_path_binding
.resolve_symbols(handler, ctx.by_ref());
let result = SymbolResolveTypeBinding::resolve_symbol(
&mut expr.call_path_binding,
&Handler::default(),
ctx.by_ref(),
);
// expr.call_path_binding
// .resolve_symbols(handler, ctx.by_ref());

let result = expr.call_path_binding.resolve_symbol(handler, ctx.by_ref());

if let Ok(result) = result {
expr.resolved_call_path_binding = Some(TypeBinding::<
ResolvedCallPath<ParsedDeclId<StructDeclaration>>,
Expand Down Expand Up @@ -597,13 +592,13 @@ impl ResolveSymbols for Expression {
.for_each(|arg| arg.resolve_symbols(handler, ctx.by_ref()));
}
ExpressionKind::Subfield(expr) => expr.prefix.resolve_symbols(handler, ctx),
ExpressionKind::DelineatedPath(ref mut expr) => {
expr.call_path_binding
.resolve_symbols(handler, ctx.by_ref());
ExpressionKind::DelineatedPath(expr) => {
// expr.call_path_binding
// .resolve_symbols(handler, ctx.by_ref());

// let result =
// expr.call_path_binding
// .resolve_symbol(handler, ctx.by_ref(), self.span.clone());
let result =
expr.call_path_binding
.resolve_symbol(handler, ctx.by_ref(), self.span.clone());

// if let Ok(result) = result {
// expr.resolved_call_path_binding = Some(TypeBinding::<
Expand Down
36 changes: 18 additions & 18 deletions sway-core/src/type_system/ast_elements/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,24 @@ impl TypeBinding<QualifiedCallPath> {
}
}

impl SymbolResolveTypeBinding<ParsedDeclId<ConstantDeclaration>> for TypeBinding<CallPath> {
fn resolve_symbol(
&mut self,
handler: &Handler,
ctx: SymbolResolveContext,
) -> Result<ParsedDeclId<ConstantDeclaration>, ErrorEmitted> {
// Grab the declaration.
let unknown_decl = ctx
.resolve_call_path_with_visibility_check(handler, &self.inner)?
.expect_parsed();

// Check to see if this is a const declaration.
let const_ref = unknown_decl.to_const_decl(handler, ctx.engines())?;

Ok(const_ref)
}
}

impl SymbolResolveTypeBinding<(ParsedDeclId<ConstantDeclaration>, TypeBinding<CallPath>)>
for TypeBinding<QualifiedCallPath>
{
Expand Down Expand Up @@ -738,21 +756,3 @@ impl TypeCheckTypeBinding<ty::TyConstantDecl> for TypeBinding<CallPath> {
Ok((const_ref, None, None))
}
}

impl SymbolResolveTypeBinding<ParsedDeclId<ConstantDeclaration>> for TypeBinding<CallPath> {
fn resolve_symbol(
&mut self,
handler: &Handler,
ctx: SymbolResolveContext,
) -> Result<ParsedDeclId<ConstantDeclaration>, ErrorEmitted> {
// Grab the declaration.
let unknown_decl = ctx
.resolve_call_path_with_visibility_check(handler, &self.inner)?
.expect_parsed();

// Check to see if this is a const declaration.
let const_ref = unknown_decl.to_const_decl(handler, ctx.engines())?;

Ok(const_ref)
}
}

0 comments on commit 367d81b

Please sign in to comment.