mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Check for specialization in typeid/T for parapoly records
This commit is contained in:
+10
-1
@@ -381,6 +381,7 @@ gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *poly
|
|||||||
Type *type = nullptr;
|
Type *type = nullptr;
|
||||||
bool is_type_param = false;
|
bool is_type_param = false;
|
||||||
bool is_type_polymorphic_type = false;
|
bool is_type_polymorphic_type = false;
|
||||||
|
Type *specialization = nullptr;
|
||||||
if (type_expr == nullptr && default_value == nullptr) {
|
if (type_expr == nullptr && default_value == nullptr) {
|
||||||
error(param, "Expected a type for this parameter");
|
error(param, "Expected a type for this parameter");
|
||||||
continue;
|
continue;
|
||||||
@@ -393,7 +394,6 @@ gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *poly
|
|||||||
}
|
}
|
||||||
if (type_expr->kind == Ast_TypeidType) {
|
if (type_expr->kind == Ast_TypeidType) {
|
||||||
is_type_param = true;
|
is_type_param = true;
|
||||||
Type *specialization = nullptr;
|
|
||||||
if (type_expr->TypeidType.specialization != nullptr) {
|
if (type_expr->TypeidType.specialization != nullptr) {
|
||||||
Ast *s = type_expr->TypeidType.specialization;
|
Ast *s = type_expr->TypeidType.specialization;
|
||||||
specialization = check_type(ctx, s);
|
specialization = check_type(ctx, s);
|
||||||
@@ -471,6 +471,15 @@ gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *poly
|
|||||||
if (is_type_polymorphic(base_type(operand.type))) {
|
if (is_type_polymorphic(base_type(operand.type))) {
|
||||||
*is_polymorphic_ = true;
|
*is_polymorphic_ = true;
|
||||||
can_check_fields = false;
|
can_check_fields = false;
|
||||||
|
} else if (specialization &&
|
||||||
|
!check_type_specialization_to(ctx, specialization, operand.type, false, /*modify_type*/true)) {
|
||||||
|
if (!ctx->no_polymorphic_errors) {
|
||||||
|
gbString t = type_to_string(operand.type);
|
||||||
|
gbString s = type_to_string(specialization);
|
||||||
|
error(operand.expr, "Cannot convert type '%s' to the specialization '%s'", t, s);
|
||||||
|
gb_string_free(s);
|
||||||
|
gb_string_free(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
e = alloc_entity_type_name(scope, token, operand.type);
|
e = alloc_entity_type_name(scope, token, operand.type);
|
||||||
e->TypeName.is_type_alias = true;
|
e->TypeName.is_type_alias = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user