-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow alias to module-self-type from module #1948
Conversation
@@ -2686,4 +2686,23 @@ module Bar : Foo | |||
end | |||
end | |||
end | |||
|
|||
def test_alias__to_module_self_indierect_method | |||
SignatureManager.new(system_builtin: false) do |manager| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really complicated to reproduce the problem.
Simply build_instance(TypeName("::Kernel"))
doesn't fail, because the self_types
are given through build_instance
method.
Building ::Foo
instance requires some of the methods of its module-self-type, ::Object
. ::Object
instance type requires the instance methods of ::Kernel
, but it's done other than #build_instance
method. So, the module-self-type
methods are not injected, and causes the problem.
@@ -86,6 +86,19 @@ def define_instance(definition, type_name, subst) | |||
one_ancestors = ancestor_builder.one_instance_ancestors(type_name) | |||
methods = method_builder.build_instance(type_name) | |||
|
|||
self_type_methods = one_ancestors.each_self_type.with_object({}) do |self_type, hash| #$ Hash[Symbol, Definition::Method] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot simply inject the self_types
methods to the result methods
/definition
, because the self_types
methods may include other inherited methods, like #initialize
and having them in the module is something unexpected.
84f7b37
to
3fe6743
Compare
Defining an alias from a module to its module-self-type causes an error like
This PR fixes the problem.