|
49 | 49 | UnaryExpr, |
50 | 50 | Var, |
51 | 51 | ) |
52 | | -from mypy.types import Instance, ProperType, TupleType, TypeType, get_proper_type |
| 52 | +from mypy.types import AnyType, Instance, ProperType, TupleType, TypeOfAny, TypeType, get_proper_type |
53 | 53 | from mypyc.common import MAX_SHORT_INT |
54 | 54 | from mypyc.ir.class_ir import ClassIR |
55 | 55 | from mypyc.ir.func_ir import FUNC_CLASSMETHOD, FUNC_STATICMETHOD |
@@ -147,12 +147,15 @@ def transform_name_expr(builder: IRBuilder, expr: NameExpr) -> Value: |
147 | 147 | return math_literal |
148 | 148 |
|
149 | 149 | if isinstance(expr.node, Var) and expr.node.is_final: |
| 150 | + typ = builder.types.get(expr) or expr.node.type |
| 151 | + if typ is None: |
| 152 | + typ = AnyType(TypeOfAny.special_form) |
150 | 153 | value = builder.emit_load_final( |
151 | 154 | expr.node, |
152 | 155 | fullname, |
153 | 156 | expr.name, |
154 | 157 | builder.is_native_ref_expr(expr), |
155 | | - builder.types[expr], |
| 158 | + typ, |
156 | 159 | expr.line, |
157 | 160 | ) |
158 | 161 | if value is not None: |
@@ -208,8 +211,11 @@ def transform_member_expr(builder: IRBuilder, expr: MemberExpr) -> Value: |
208 | 211 | final = builder.get_final_ref(expr) |
209 | 212 | if final is not None: |
210 | 213 | fullname, final_var, native = final |
| 214 | + typ = builder.types.get(expr) or final_var.type |
| 215 | + if typ is None: |
| 216 | + typ = AnyType(TypeOfAny.special_form) |
211 | 217 | value = builder.emit_load_final( |
212 | | - final_var, fullname, final_var.name, native, builder.types[expr], expr.line |
| 218 | + final_var, fullname, final_var.name, native, typ, expr.line |
213 | 219 | ) |
214 | 220 | if value is not None: |
215 | 221 | return value |
|
0 commit comments