@@ -707,14 +707,15 @@ fn (mut c Checker) smartcast_if_conds(mut node ast.Expr, mut scope ast.Scope, co
707
707
right_sym := c.table.sym (right_type)
708
708
mut expr_type := c.unwrap_generic (node.left_type)
709
709
left_sym := c.table.sym (expr_type)
710
+ left_final_sym := c.table.final_sym (expr_type)
710
711
if left_sym.kind == .aggregate {
711
712
expr_type = (left_sym.info as ast.Aggregate ).sum_type
712
713
}
713
714
if left_sym.kind == .interface {
714
715
if right_sym.kind != .interface {
715
716
c.type_implements (right_type, expr_type, node.pos)
716
717
}
717
- } else if ! c.check_types (right_type, expr_type) && left_sym .kind != .sum_type {
718
+ } else if ! c.check_types (right_type, expr_type) && left_final_sym .kind != .sum_type {
718
719
expect_str := c.table.type_to_str (right_type)
719
720
expr_str := c.table.type_to_str (expr_type)
720
721
c.error ('cannot use type `${expect_str} ` as type `${expr_str} `' , node.pos)
@@ -740,7 +741,7 @@ fn (mut c Checker) smartcast_if_conds(mut node ast.Expr, mut scope ast.Scope, co
740
741
node.left.pos)
741
742
}
742
743
}
743
- if left_sym .kind in [.interface , .sum_type] {
744
+ if left_final_sym .kind in [.interface , .sum_type] {
744
745
c.smartcast (mut node.left, node.left_type, right_type, mut
745
746
scope, is_comptime, false )
746
747
}
0 commit comments