diff --git a/src/compiler/crystal/tools/expand.cr b/src/compiler/crystal/tools/expand.cr index 09bab30ad629..2c352a47ecc7 100644 --- a/src/compiler/crystal/tools/expand.cr +++ b/src/compiler/crystal/tools/expand.cr @@ -67,7 +67,7 @@ module Crystal class ExpandVisitor < Visitor def initialize(@target_location : Location) @nodes = [] of ASTNode - @in_def_instance = false + @in_defs = false @message = "no expansion found" end @@ -83,9 +83,7 @@ module Crystal if type.is_a?(DefInstanceContainer) type.def_instances.values.try do |typed_defs| typed_defs.each do |typed_def| - @in_def_instance = true typed_def.accept(self) - @in_def_instance = false end end end @@ -98,15 +96,15 @@ module Crystal end def process(result : Compiler::Result) + @in_defs = true result.program.def_instances.each_value do |typed_def| - @in_def_instance = true typed_def.accept(self) - @in_def_instance = false end result.program.types?.try &.values.each do |type| process_type type end + @in_defs = false result.node.accept(self) @@ -120,7 +118,7 @@ module Crystal end def visit(node : Def | FunDef) - @in_def_instance && contains_target(node) + @in_defs && contains_target(node) end def visit(node : Call)