67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/finalist.rb', line 67
def extended(base)
def base.singleton_method_added(symbol)
super
meth = singleton_class.instance_method(symbol)
super_method = meth.super_method
while super_method
if Finalist.finalized_methods[super_method.owner]&.member?(super_method.name)
@__finalist_tp&.disable
@__finalist_tp = nil
raise OverrideFinalMethodError.new("#{super_method} at #{super_method.source_location.join(":")} is overrided\n by #{meth} at #{meth.source_location.join(":")}", singleton_class, super_method.owner, meth, :extended_singleton_method_added)
end
super_method = super_method.super_method
end
end
base.singleton_class.ancestors.drop(1).each do |mod|
Finalist.finalized_methods[mod]&.each do |fmeth_name|
if meth = base.singleton_class.instance_method(fmeth_name)
super_method = meth.super_method
while super_method
if Finalist.finalized_methods[super_method.owner]&.member?(super_method.name)
base.instance_variable_get("@__finalist_tp")&.disable
base.instance_variable_set("@__finalist_tp", nil)
raise OverrideFinalMethodError.new("#{super_method} at #{super_method.source_location.join(":")} is overrided\n by #{meth} at #{meth.source_location.join(":")}", base.singleton_class, super_method.owner, meth, :extended)
end
super_method = super_method.super_method
end
end
end
end
end
|