Skip to content

Commit

Permalink
Revert "Fix context tool"
Browse files Browse the repository at this point in the history
It is fixed in crystal-lang#3751. Yeah, we need no hack for it!

This reverts commit 1d26d45.
  • Loading branch information
makenowjust committed Dec 27, 2016
1 parent 8eb3d72 commit dcee155
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/compiler/crystal/tools/context.cr
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ module Crystal
@contexts = Array(HashStringType).new
@context = HashStringType.new
@def_with_yield = nil
@in_defs = false
end

def process_instance_defs(type)
Expand Down Expand Up @@ -158,15 +157,13 @@ module Crystal
end

def process(result : Compiler::Result)
@in_defs = true
result.program.def_instances.each_value do |typed_def|
visit_and_append_context typed_def
end

result.program.types?.try &.values.each do |type|
process_type type
end
@in_defs = false

if @contexts.empty?
@context = HashStringType.new
Expand Down Expand Up @@ -292,10 +289,9 @@ module Crystal
private def contains_target(node)
if loc_start = node.location
loc_end = node.end_location || loc_start
# if it is not between, it could be the case that node is the top level Expressions,
# if it is not between, it could be the case that node is the top level Expressions
# in which the (start) location might be in one file and the end location in another.
@target_location.between?(loc_start, loc_end) || (!@in_defs && loc_start.filename != loc_end.filename)
# When node generated by macro and macro has yielding block, it also makes `loc_start.filename != loc_end.filename` true.
@target_location.between?(loc_start, loc_end) || loc_start.filename != loc_end.filename
else
# if node has no location, assume they may contain the target.
# for example with the main expressions ast node this matters
Expand Down

0 comments on commit dcee155

Please sign in to comment.