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 method3-
# (Sqlite.find) to be DCE'd as a "transplanted source". The transplant check4-
# must match the class hierarchy, not just the method name -- otherwise the5-
# adapter's find is called but never emitted (undefined reference).6-
7-
class Sqlite8-
def self.find(table, id)9-
"sql-#{table}-#{id}"10-
end11-
end12-
module AR13-
class << self14-
attr_accessor :adapter15-
end16-
end17-
AR.adapter = Sqlite18-
class Base19-
def self.table_name20-
"base"21-
end22-
def self.find(id)23-
AR.adapter.find(table_name, id)24-
end25-
end26-
class Article < Base27-
def self.table_name28-
"articles"29-
end30-
end31-
class Comment < Base32-
def self.table_name33-
"comments"34-
end35-
end36-
puts Article.find(5)37-
puts Comment.find(9)38-
puts Base.find(1)test/cls_method_name_collision_dce.rb.expecteddeleted
Loading diff…