Commit bb161a5c

bb161a5c2c88Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · -2 deleted

Description

test: adopt the cmethod-specialization DCE regression test from #1418

The fix for the class-method specialization DCE name-collision (6ca9d91) was also independently found and fixed by @rubys in #1418, who filed first. Adopt his regression test (cmethod_specialize_samename_unrelated) and drop the near-identical one I had added, so his contribution is the one recorded.

Refs #1314 Closes #1418

Co-Authored-By: Sam Ruby [email protected] Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
bb161a5c2c88
Parent
6313ab74d277

test/cls_method_name_collision_dce.rbdeleted

1-# A class method specialized into subclasses (Base.find -> Article.find /
2-# Comment.find) must not cause an unrelated class's same-named class method
3-# (Sqlite.find) to be DCE'd as a "transplanted source". The transplant check
4-# must match the class hierarchy, not just the method name -- otherwise the
5-# adapter's find is called but never emitted (undefined reference).
6-
7-class Sqlite
8- def self.find(table, id)
9- "sql-#{table}-#{id}"
10- end
11-end
12-module AR
13- class << self
14- attr_accessor :adapter
15- end
16-end
17-AR.adapter = Sqlite
18-class Base
19- def self.table_name
20- "base"
21- end
22- def self.find(id)
23- AR.adapter.find(table_name, id)
24- end
25-end
26-class Article < Base
27- def self.table_name
28- "articles"
29- end
30-end
31-class Comment < Base
32- def self.table_name
33- "comments"
34- end
35-end
36-puts Article.find(5)
37-puts Comment.find(9)
38-puts Base.find(1)