@@ -145,7 +145,7 @@ def prepare(typer, method)
145
145
mirah = typer . transformer
146
146
interface = method . argument_types [ -1 ]
147
147
outer_class = scope . defining_class
148
-
148
+
149
149
binding = scope . binding_type ( mirah )
150
150
151
151
name = "#{ outer_class . name } $#{ mirah . tmp } "
@@ -157,6 +157,8 @@ def prepare(typer, method)
157
157
mirah . eval ( "@binding = binding" , '-' , c , 'binding' )
158
158
end
159
159
160
+ @defining_class = klass . static_scope . self_type
161
+
160
162
# TODO We need a special scope here that allows access to the
161
163
# outer class.
162
164
static_scope . self_type = typer . infer ( klass , true )
@@ -174,6 +176,15 @@ def prepare(typer, method)
174
176
typer . infer ( instance , true )
175
177
end
176
178
179
+ def defining_class
180
+ @defining_class
181
+ end
182
+
183
+ # TODO extract this & matching methods into a module
184
+ def binding_type ( mirah = nil )
185
+ static_scope . binding_type ( defining_class , mirah )
186
+ end
187
+
177
188
def add_methods ( klass , binding , typer )
178
189
method_definitions = body . select { |node | node . kind_of? MethodDefinition }
179
190
@@ -183,8 +194,10 @@ def add_methods(klass, binding, typer)
183
194
# TODO warn if there are non method definition nodes
184
195
# they won't be used at all currently--so it'd be nice to note that.
185
196
method_definitions . each do |node |
197
+
186
198
node . static_scope = static_scope
187
199
node . binding_type = binding
200
+ # node.children.each {|child| child.instance_variable_set '@scope', nil }
188
201
klass . append_node ( node )
189
202
end
190
203
end
0 commit comments