lib/tapioca/gem/pipeline.rb in tapioca-0.10.1 vs lib/tapioca/gem/pipeline.rb in tapioca-0.10.2
- old
+ new
@@ -89,11 +89,11 @@
symbol: String,
constant: Module,
method: UnboundMethod,
node: RBI::Method,
signature: T.untyped,
- parameters: T::Array[[Symbol, String]]
+ parameters: T::Array[[Symbol, String]],
).void.checked(:never)
end
def push_method(symbol, constant, method, node, signature, parameters) # rubocop:disable Metrics/ParameterLists
@events << Gem::MethodNodeAdded.new(symbol, constant, method, node, signature, parameters)
end
@@ -160,11 +160,11 @@
def on_symbol(event)
symbol = event.symbol.delete_prefix("::")
return if symbol_in_payload?(symbol) && !@bootstrap_symbols.include?(symbol)
constant = constantize(symbol)
- push_constant(symbol, constant) if constant
+ push_constant(symbol, constant) if Runtime::Reflection.constant_defined?(constant)
end
sig { params(event: Gem::ConstantFound).void.checked(:never) }
def on_constant(event)
name = event.symbol
@@ -258,10 +258,11 @@
end
return if klass_name&.start_with?("T::Types::", "T::Private::")
type_name = klass_name || "T.untyped"
+ type_name = "T.untyped" if type_name == "NilClass"
node = RBI::Const.new(name, "T.let(T.unsafe(nil), #{type_name})")
push_const(name, klass, node)
@root << node
end
@@ -319,11 +320,11 @@
# B #=> A
superclass_name = name_of(superclass)
next unless superclass_name
resolved_superclass = constantize(superclass_name)
- next unless Module === resolved_superclass
+ next unless Module === resolved_superclass && Runtime::Reflection.constant_defined?(resolved_superclass)
next if name_of(resolved_superclass) == constant_name
# We found a suitable superclass
break
end
@@ -387,9 +388,12 @@
type_name = T.must(constant.name)
return type_name if type_name =~ /\[.*\]$/
type_variables = Runtime::GenericTypeRegistry.lookup_type_variables(constant)
return type_name unless type_variables
+
+ type_variables = type_variables.reject(&:fixed?)
+ return type_name if type_variables.empty?
type_variable_names = type_variables.map { "T.untyped" }.join(", ")
"#{type_name}[#{type_variable_names}]"
end