lib/rbs/definition_builder/ancestor_builder.rb in rbs-3.5.3 vs lib/rbs/definition_builder/ancestor_builder.rb in rbs-3.6.0.dev.1

- old
+ new

@@ -211,16 +211,19 @@ super_name = BuiltinNames::Object.name super_args = [] end super_name = env.normalize_module_name(super_name) - + NoSuperclassFoundError.check!(super_name, env: env, location: primary.decl.location) if super_class InheritModuleError.check!(super_class, env: env) end + super_entry = env.normalized_class_entry(super_name) or raise + super_args = AST::TypeParam.normalize_args(super_entry.type_params, super_args) + ancestors = OneAncestors.class_instance( type_name: type_name, params: params, super_class: Definition::Ancestor::Instance.new(name: super_name, args: super_args, source: :super) ) @@ -241,13 +244,21 @@ entry.self_types.each do |module_self| NoSelfTypeFoundError.check!(module_self, env: env) module_name = module_self.name if module_name.class? - module_name = env.normalize_module_name(module_name) + module_entry = env.normalized_module_class_entry(module_name) or raise + module_name = module_entry.name + self_args = AST::TypeParam.normalize_args(module_entry.type_params, module_self.args) end - self_types.push Definition::Ancestor::Instance.new(name: module_name, args: module_self.args, source: module_self) + if module_name.interface? + interface_entry = env.interface_decls.fetch(module_name) + self_args = AST::TypeParam.normalize_args(interface_entry.decl.type_params, module_self.args) + end + self_args or raise + + self_types.push Definition::Ancestor::Instance.new(name: module_name, args: self_args, source: module_self) end end end mixin_ancestors(entry, @@ -344,25 +355,34 @@ case when member.name.class? && included_modules MixinClassError.check!(type_name: type_name, env: env, member: member) NoMixinFoundError.check!(member.name, env: env, member: member) + module_decl = env.normalized_module_entry(module_name) or raise + module_args = AST::TypeParam.normalize_args(module_decl.type_params, module_args) + module_name = env.normalize_module_name(module_name) included_modules << Definition::Ancestor::Instance.new(name: module_name, args: module_args, source: member) when member.name.interface? && included_interfaces NoMixinFoundError.check!(member.name, env: env, member: member) + interface_decl = env.interface_decls.fetch(module_name) + module_args = AST::TypeParam.normalize_args(interface_decl.decl.type_params, module_args) + included_interfaces << Definition::Ancestor::Instance.new(name: module_name, args: module_args, source: member) end when AST::Members::Prepend if prepended_modules MixinClassError.check!(type_name: type_name, env: env, member: member) NoMixinFoundError.check!(member.name, env: env, member: member) - module_name = env.normalize_module_name(member.name) + module_decl = env.normalized_module_entry(member.name) or raise + module_name = module_decl.name + module_args = member.args.map {|type| align_params ? type.sub(align_params) : type } + module_args = AST::TypeParam.normalize_args(module_decl.type_params, module_args) prepended_modules << Definition::Ancestor::Instance.new(name: module_name, args: module_args, source: member) end when AST::Members::Extend @@ -372,13 +392,19 @@ case when member.name.class? && extended_modules MixinClassError.check!(type_name: type_name, env: env, member: member) NoMixinFoundError.check!(member.name, env: env, member: member) + module_decl = env.normalized_module_entry(module_name) or raise + module_args = AST::TypeParam.normalize_args(module_decl.type_params, module_args) + module_name = env.normalize_module_name(module_name) extended_modules << Definition::Ancestor::Instance.new(name: module_name, args: module_args, source: member) when member.name.interface? && extended_interfaces NoMixinFoundError.check!(member.name, env: env, member: member) + + interface_decl = env.interface_decls.fetch(module_name) + module_args = AST::TypeParam.normalize_args(interface_decl.decl.type_params, module_args) extended_interfaces << Definition::Ancestor::Instance.new(name: module_name, args: module_args, source: member) end end end