Commit dc997904
dc9979041919Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
Merge pull request #187 from mame/pr/subclass-parent-prefix
fix(codegen): resolve subclass parent through enclosing module chain
Details
- Commit
- dc9979041919
- Parent
- 013dff7b0140
- Merge parent
- 313a87a3eb28
spinel_codegen.rbmodifiedView file
@@ -5082,7 +5082,34 @@
50825082
end50835083
end50845084
else5085-
parent = @nd_name[sp]5085+
parent = const_ref_flat_name(sp)5086+
if parent == ""5087+
parent = @nd_name[sp]5088+
end5089+
# Resolve the parent class name against the same module-prefix5090+
# chain that was used to register the child. `class Sub < Base`5091+
# inside `module M` should land on `M_Base` (the registered5092+
# name), not bare "Base", or `emit_class_fields` later fails5093+
# `find_class_idx` and silently drops every inherited field.5094+
if module_prefix != "" && const_ref_is_relative(sp) == 15095+
if find_class_idx(parent) < 05096+
mp = module_prefix5097+
while mp != ""5098+
cand = mp + "_" + parent5099+
if find_class_idx(cand) >= 05100+
parent = cand5101+
mp = ""5102+
else5103+
idx = mp.rindex("_")5104+
if idx < 05105+
mp = ""5106+
else5107+
mp = mp[0, idx]5108+
end5109+
end5110+
end5111+
end5112+
end50865113
end50875114
end50885115
test/subclass_inherits_module_parent.rbaddedView file
Loading diff…