Support conversion from T* to const T*. (#5971)

Also support conversion from Derived* to const Base*.

---------

Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
This commit is contained in:
Richard Smith
2025-08-20 23:27:03 +00:00
committed by GitHub
co-authored by josh11b
parent ad84e71acd
commit 30b8a93fde
10 changed files with 580 additions and 315 deletions
+10
View File
@@ -136,6 +136,16 @@ auto GetConstType(Context& context, SemIR::TypeInstId inner_type_id)
return GetTypeImpl<SemIR::ConstType>(context, inner_type_id);
}
auto GetQualifiedType(Context& context, SemIR::TypeId type_id,
SemIR::TypeQualifiers quals) -> SemIR::TypeId {
if ((quals & SemIR::TypeQualifiers::Const) != SemIR::TypeQualifiers::None) {
type_id = GetConstType(context, context.types().GetInstId(type_id));
quals &= ~SemIR::TypeQualifiers::Const;
}
CARBON_CHECK(quals == SemIR::TypeQualifiers::None);
return type_id;
}
auto GetSingletonType(Context& context, SemIR::TypeInstId singleton_id)
-> SemIR::TypeId {
CARBON_CHECK(SemIR::IsSingletonInstId(singleton_id));