Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): fix select_trait_candidate #478

Merged
merged 4 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions engine/lib/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ functor
| ImplApp of { impl : impl_expr; args : impl_expr list }
| Dyn of trait_ref
| Builtin of trait_ref
| FnPointer of ty
(* The `IE` suffix is there because visitors conflicts...... *)
| ClosureIE of todo

and trait_ref = { trait : concrete_ident; args : generic_value list }

Expand Down
8 changes: 5 additions & 3 deletions engine/lib/import_thir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -922,25 +922,27 @@ end) : EXPR = struct
let trait = Concrete_ident.of_def_id Impl id in
let args = List.map ~f:(c_generic_value span) generics in
Concrete { trait; args }
| LocalBound { clause_id; path } ->
| LocalBound { clause_id; path; _ } ->
let init = LocalBound { id = clause_id } in
let f (impl : impl_expr) (chunk : Thir.impl_expr_path_chunk) =
match chunk with
| AssocItem (item, { trait_ref; _ }) ->
| AssocItem { item; predicate = { trait_ref; _ }; _ } ->
let trait = c_trait_ref span trait_ref in
let kind : Concrete_ident.Kind.t =
match item.kind with Const | Fn -> Value | Type -> Type
in
let item = Concrete_ident.of_def_id kind item.def_id in
Projection { impl; trait; item }
| Parent { trait_ref; _ } ->
| Parent { predicate = { trait_ref; _ }; _ } ->
let trait = c_trait_ref span trait_ref in
Parent { impl; trait }
in
List.fold ~init ~f path
| Dyn { trait } -> Dyn (c_trait_ref span trait)
| SelfImpl -> Self
| Builtin { trait } -> Builtin (c_trait_ref span trait)
| FnPointer { fn_ty } -> FnPointer (c_ty span fn_ty)
| Closure _ as x -> ClosureIE ([%show: Thir.impl_expr_atom] x)
| Todo str -> failwith @@ "impl_expr_atom: Todo " ^ str

and c_generic_value (span : Thir.span) (ty : Thir.generic_arg) : generic_value
Expand Down
2 changes: 2 additions & 0 deletions engine/lib/subtype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ struct
}
| Dyn tr -> Dyn (dtrait_ref span tr)
| Builtin tr -> Builtin (dtrait_ref span tr)
| ClosureIE todo -> ClosureIE todo
| FnPointer ty -> FnPointer (dty span ty)

and dgeneric_value (span : span) (generic_value : A.generic_value) :
B.generic_value =
Expand Down
Loading
Loading