mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Look for final impl when accessing associated constant in facet (#5269)
While facets may come with a rewrite for an associated constant, they are symbolic. A final impl has the ability to provide a concrete value instead, which allows generic code to use the concrete value in place of the associated constant's (fully qualified) name. For instance, instead of `I.Type`, the concrete type `()` can be used if there is an `impl final [T:! type] T as I where .Type = ()` impl. This does not yet cache the result of the lookups. Depends on https://github.com/carbon-language/carbon-lang/pull/5255 --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
68111a994c
commit
76c68153a2
@@ -249,4 +249,10 @@ auto FillImplWitnessWithErrors(Context& context, SemIR::Impl& impl) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto IsImplEffectivelyFinal(Context& context, const SemIR::Impl& impl) -> bool {
|
||||
return impl.is_final ||
|
||||
(context.constant_values().Get(impl.self_id).is_concrete() &&
|
||||
context.constant_values().Get(impl.constraint_id).is_concrete());
|
||||
}
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
Reference in New Issue
Block a user