Skip to content

Commit 6d067f2

Browse files
committed
Unconst input and output args when checking method overrides
1 parent f054151 commit 6d067f2

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

py/dml/c_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,13 +811,13 @@ def generate_implement_method(device, ifacestruct, meth, indices):
811811
# method in DML
812812
raise EMETH(meth.site, None, 'interface method is variadic')
813813
for ((mp, mt), it) in zip(meth.inp, iface_input_types):
814-
if safe_realtype(mt).cmp(safe_realtype(it)) != 0:
814+
if safe_realtype_unconst(mt).cmp(safe_realtype_unconst(it)) != 0:
815815
raise EARGT(meth.site, 'implement', meth.name,
816816
mt, mp, it, 'method')
817817
if iface_num_outputs and dml.globals.dml_version != (1, 2):
818818
[(_, mt)] = meth.outp
819-
if safe_realtype(mt).cmp(
820-
safe_realtype(ifacemethtype.output_type)) != 0:
819+
if safe_realtype_unconst(mt).cmp(
820+
safe_realtype_unconst(ifacemethtype.output_type)) != 0:
821821
raise EARGT(meth.site, 'implement', meth.name,
822822
mt, '<return value>', ifacemethtype.output_type,
823823
'method')

py/dml/ctree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,8 +3160,8 @@ def mkInterfaceMethodRef(site, iface_node, indices, method_name):
31603160

31613161
if (not isinstance(ftype, TFunction)
31623162
or not ftype.input_types
3163-
or TPtr(safe_realtype(TNamed('conf_object_t'))).cmp(
3164-
safe_realtype(ftype.input_types[0])) != 0):
3163+
or TPtr(safe_realtype_unconst(TNamed('conf_object_t'))).cmp(
3164+
safe_realtype_unconst(ftype.input_types[0])) != 0):
31653165
# non-method members are not accessible
31663166
raise EMEMBER(site, struct_name, method_name)
31673167

py/dml/structure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,8 @@ def typecheck_method_override(m1, m2):
674674
# TODO move to caller
675675
(_, type1) = eval_type(t1, a1.site, None, global_scope)
676676
(_, type2) = eval_type(t2, a2.site, None, global_scope)
677-
if safe_realtype(type1).cmp(safe_realtype(type2)) != 0:
677+
if safe_realtype_unconst(type1).cmp(
678+
safe_realtype_unconst(type2)) != 0:
678679
raise EMETH(a1.site, a2.site,
679680
f"mismatching types in input argument {n1}")
680681

@@ -683,7 +684,8 @@ def typecheck_method_override(m1, m2):
683684
((n1, t1), (n2, t2)) = (a1.args, a2.args)
684685
(_, type1) = eval_type(t1, a1.site, None, global_scope)
685686
(_, type2) = eval_type(t2, a2.site, None, global_scope)
686-
if safe_realtype(type1).cmp(safe_realtype(type2)) != 0:
687+
if safe_realtype_unconst(type1).cmp(
688+
safe_realtype_unconst(type2)) != 0:
687689
msg = "mismatching types in return value"
688690
if len(outp1) > 1:
689691
msg += f" {i + 1}"

py/dml/traits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ def typecheck_method_override(left, right):
394394
if throws0 != throws1:
395395
raise EMETH(site0, site1, "different nothrow annotations")
396396
for ((n, t0), (_, t1)) in zip(inp0, inp1):
397-
if realtype(t0).cmp(realtype(t1)) != 0:
397+
if safe_realtype_unconst(t0).cmp(safe_realtype_unconst(t1)) != 0:
398398
raise EMETH(site0, site1,
399399
"mismatching types in input argument %s" % (n,))
400400
for (i, ((_, t0), (_, t1))) in enumerate(zip(outp0, outp1)):
401-
if realtype(t0).cmp(realtype(t1)) != 0:
401+
if safe_realtype_unconst(t0).cmp(safe_realtype_unconst(t1)) != 0:
402402
raise EMETH(site0, site1,
403403
"mismatching types in output argument %d" % (i + 1,))
404404

py/dml/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,14 +886,14 @@ def cmp_fuzzy(self, other, consider_quals=False):
886886
cconst = conv_const if consider_quals else lambda c, t: t
887887
if not dml.globals.compat_dml12:
888888
if isinstance(other, (TArray, TPtr)):
889-
return cconst(self.const, self.base).cmp(
889+
return cconst(self.const, self.base).cmp_fuzzy(
890890
cconst(other.const and isinstance(other, TArray),
891891
other.base),
892892
consider_quals)
893893
elif isinstance(other, (TPtr, TArray)):
894894
if self.base.void or other.base.void:
895895
return 0
896-
if (cconst(self.const, self.base).cmp(
896+
if (cconst(self.const, self.base).cmp_fuzzy(
897897
cconst(other.const and isinstance(other, TArray),
898898
other.base), consider_quals) == 0):
899899
return 0

0 commit comments

Comments
 (0)