@@ -145,7 +145,7 @@ def prepare(typer, method)
145145 mirah = typer . transformer
146146 interface = method . argument_types [ -1 ]
147147 outer_class = scope . defining_class
148-
148+
149149 binding = scope . binding_type ( mirah )
150150
151151 name = "#{ outer_class . name } $#{ mirah . tmp } "
@@ -157,6 +157,8 @@ def prepare(typer, method)
157157 mirah . eval ( "@binding = binding" , '-' , c , 'binding' )
158158 end
159159
160+ @defining_class = klass . static_scope . self_type
161+
160162 # TODO We need a special scope here that allows access to the
161163 # outer class.
162164 static_scope . self_type = typer . infer ( klass , true )
@@ -174,6 +176,15 @@ def prepare(typer, method)
174176 typer . infer ( instance , true )
175177 end
176178
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+
177188 def add_methods ( klass , binding , typer )
178189 method_definitions = body . select { |node | node . kind_of? MethodDefinition }
179190
@@ -183,8 +194,10 @@ def add_methods(klass, binding, typer)
183194 # TODO warn if there are non method definition nodes
184195 # they won't be used at all currently--so it'd be nice to note that.
185196 method_definitions . each do |node |
197+
186198 node . static_scope = static_scope
187199 node . binding_type = binding
200+ # node.children.each {|child| child.instance_variable_set '@scope', nil }
188201 klass . append_node ( node )
189202 end
190203 end
0 commit comments