Fallback to method resolution on unresolved field access with matching method name

This commit is contained in:
Lukas Wirth 2023-12-08 16:36:41 +01:00
parent 9c3de09f6d
commit 35fbc0210c
5 changed files with 140 additions and 72 deletions

View file

@ -492,7 +492,7 @@ impl NameRefClass {
match_ast! {
match parent {
ast::MethodCallExpr(method_call) => {
sema.resolve_method_call_field_fallback(&method_call)
sema.resolve_method_call_fallback(&method_call)
.map(|it| {
it.map_left(Definition::Function)
.map_right(Definition::Field)
@ -500,9 +500,12 @@ impl NameRefClass {
})
},
ast::FieldExpr(field_expr) => {
sema.resolve_field(&field_expr)
.map(Definition::Field)
.map(NameRefClass::Definition)
sema.resolve_field_fallback(&field_expr)
.map(|it| {
it.map_left(Definition::Field)
.map_right(Definition::Function)
.either(NameRefClass::Definition, NameRefClass::Definition)
})
},
ast::RecordPatField(record_pat_field) => {
sema.resolve_record_pat_field(&record_pat_field)