Fix TokenRange for assoc function self
This commit is contained in:
parent
48dd17b320
commit
d9911a8ff5
@ -343,6 +343,17 @@ pub fn analyze_context(context: &mir::Context, module: &mir::Module, error: Opti
|
||||
for (_, function) in &module.associated_functions {
|
||||
for param in &function.parameters {
|
||||
scope.state.init_types(¶m.meta, Some(param.ty.clone()));
|
||||
|
||||
if param.meta.source_module_id == module.module_id {
|
||||
dbg!(param);
|
||||
let idx = scope
|
||||
.token_idx(¶m.meta, |t| matches!(t, Token::Identifier(_)))
|
||||
.unwrap_or(function.signature().range.end);
|
||||
dbg!(idx, scope.tokens.get(idx));
|
||||
let symbol = scope.state.new_symbol(idx, SemanticKind::Variable);
|
||||
scope.state.set_symbol(idx, symbol);
|
||||
scope.variables.insert(param.name.clone(), symbol);
|
||||
}
|
||||
}
|
||||
|
||||
match &function.kind {
|
||||
@ -366,7 +377,6 @@ pub fn analyze_context(context: &mir::Context, module: &mir::Module, error: Opti
|
||||
|
||||
for param in &function.parameters {
|
||||
scope.state.init_types(¶m.meta, Some(param.ty.clone()));
|
||||
dbg!(param);
|
||||
if param.meta.source_module_id == module.module_id {
|
||||
let idx = scope
|
||||
.token_idx(¶m.meta, |t| matches!(t, Token::Identifier(_)))
|
||||
|
@ -1168,11 +1168,11 @@ impl Parse for AssociatedFunctionBlock {
|
||||
match stream.peek() {
|
||||
Some(Token::FnKeyword) | Some(Token::PubKeyword) => {
|
||||
let mut fun: FunctionDefinition = stream.parse()?;
|
||||
fun.0.self_kind = match fun.0.self_kind {
|
||||
SelfKind::Owned(_) => SelfKind::Owned(ty.clone()),
|
||||
SelfKind::Borrow(_) => SelfKind::Borrow(ty.clone()),
|
||||
SelfKind::MutBorrow(_) => SelfKind::MutBorrow(ty.clone()),
|
||||
SelfKind::None => SelfKind::None,
|
||||
match &mut fun.0.self_kind {
|
||||
SelfKind::Owned(inner_ty) => inner_ty.0 = ty.0.clone(),
|
||||
SelfKind::Borrow(inner_ty) => inner_ty.0 = ty.0.clone(),
|
||||
SelfKind::MutBorrow(inner_ty) => inner_ty.0 = ty.0.clone(),
|
||||
SelfKind::None => {}
|
||||
};
|
||||
functions.push(fun);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user