mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 21:10:30 +00:00
Fix instantiation of package for parapoly records
This commit is contained in:
@@ -286,9 +286,20 @@ gb_internal GenTypesData *ensure_polymorphic_record_entity_has_gen_types(Checker
|
||||
|
||||
gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, Type *named_type, Type *original_type) {
|
||||
GB_ASSERT(is_type_named(named_type));
|
||||
GB_ASSERT(original_type->kind == Type_Named);
|
||||
gbAllocator a = heap_allocator();
|
||||
Scope *s = ctx->scope->parent;
|
||||
|
||||
AstPackage *pkg = nullptr;
|
||||
if (original_type->Named.type_name && original_type->Named.type_name->pkg) {
|
||||
pkg = original_type->Named.type_name->pkg;
|
||||
}
|
||||
|
||||
if (pkg == nullptr) {
|
||||
// NOTE(bill): if the `pkg` cannot be determined, default to the current context's pkg instead
|
||||
pkg = ctx->pkg;
|
||||
}
|
||||
|
||||
Entity *e = nullptr;
|
||||
{
|
||||
Token token = ast_token(node);
|
||||
@@ -300,12 +311,11 @@ gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, T
|
||||
e = alloc_entity_type_name(s, token, named_type);
|
||||
e->state = EntityState_Resolved;
|
||||
e->file = ctx->file;
|
||||
e->pkg = ctx->pkg;
|
||||
e->pkg = pkg;
|
||||
add_entity_use(ctx, node, e);
|
||||
}
|
||||
|
||||
named_type->Named.type_name = e;
|
||||
GB_ASSERT(original_type->kind == Type_Named);
|
||||
e->TypeName.objc_class_name = original_type->Named.type_name->TypeName.objc_class_name;
|
||||
// TODO(bill): Is this even correct? Or should the metadata be copied?
|
||||
e->TypeName.objc_metadata = original_type->Named.type_name->TypeName.objc_metadata;
|
||||
|
||||
Reference in New Issue
Block a user