Skip to content

Instantly share code, notes, and snippets.

@asterite
Created August 4, 2015 14:32
Show Gist options
  • Save asterite/bec416c9c42a389aca39 to your computer and use it in GitHub Desktop.
Save asterite/bec416c9c42a389aca39 to your computer and use it in GitHub Desktop.
diff --git a/src/compiler/crystal/codegen/ast.cr b/src/compiler/crystal/codegen/ast.cr
index d42583e..f1453f7 100644
--- a/src/compiler/crystal/codegen/ast.cr
+++ b/src/compiler/crystal/codegen/ast.cr
@@ -69,6 +69,10 @@ module Crystal
next_def = next_def.next
end
+ if used_by_old_call
+ str << "_" << object_id
+ end
+
needs_self_type = self_type.try &.passed_as_self?
if args.length > 0 || needs_self_type || uses_block_arg
diff --git a/src/compiler/crystal/semantic/ast.cr b/src/compiler/crystal/semantic/ast.cr
index 3e76394..913c515 100644
--- a/src/compiler/crystal/semantic/ast.cr
+++ b/src/compiler/crystal/semantic/ast.cr
@@ -222,6 +222,9 @@ module Crystal
property :visibility
getter :special_vars
+ property :used_by_old_call
+ @used_by_old_call = false
+
def macro_owner=(@macro_owner)
end
diff --git a/src/compiler/crystal/types.cr b/src/compiler/crystal/types.cr
index 345d439..14fb61a 100644
--- a/src/compiler/crystal/types.cr
+++ b/src/compiler/crystal/types.cr
@@ -578,6 +578,7 @@ module Crystal
if ex_item.is_restriction_of?(item, self)
list[i] = item
a_def.previous = ex_item.def
+ clear_def_instance_cache ex_item.def.object_id
return ex_item.def
else
list.insert(i, item)
@@ -589,6 +590,19 @@ module Crystal
nil
end
+ def clear_def_instance_cache(def_object_id)
+ found_instance = false
+ @def_instances.try &.delete_if do |key, existing_def|
+ match = key.def_object_id == def_object_id
+ if match
+ existing_def.used_by_old_call = true
+ found_instance = true
+ end
+ match
+ end
+ found_instance
+ end
+
def undef(def_name)
found_list = @defs.try &.delete def_name
return false unless found_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment