lib/steep/interface/builder.rb in steep-1.6.0.pre.2 vs lib/steep/interface/builder.rb in steep-1.6.0.pre.3
- old
+ new
@@ -1,6 +1,5 @@
-
module Steep
module Interface
class Builder
class Config
attr_reader :self_type, :class_type, :instance_type, :variable_bounds
@@ -716,27 +715,35 @@
member = method_def.member
if member.is_a?(RBS::AST::Members::MethodDefinition)
case method_name.method_name
when :is_a?, :kind_of?, :instance_of?
- if defined_in == RBS::BuiltinNames::Object.name && member.instance?
- return method_type.with(
- type: method_type.type.with(
- return_type: AST::Types::Logic::ReceiverIsArg.new(location: method_type.type.return_type.location)
+ case
+ when RBS::BuiltinNames::Object.name,
+ RBS::BuiltinNames::Kernel.name
+ if member.instance?
+ return method_type.with(
+ type: method_type.type.with(
+ return_type: AST::Types::Logic::ReceiverIsArg.new(location: method_type.type.return_type.location)
+ )
)
- )
+ end
end
when :nil?
case defined_in
- when RBS::BuiltinNames::Object.name, AST::Builtin::NilClass.module_name
- return method_type.with(
- type: method_type.type.with(
- return_type: AST::Types::Logic::ReceiverIsNil.new(location: method_type.type.return_type.location)
+ when RBS::BuiltinNames::Object.name,
+ AST::Builtin::NilClass.module_name,
+ RBS::BuiltinNames::Kernel.name
+ if member.instance?
+ return method_type.with(
+ type: method_type.type.with(
+ return_type: AST::Types::Logic::ReceiverIsNil.new(location: method_type.type.return_type.location)
+ )
)
- )
end
+ end
when :!
case defined_in
when RBS::BuiltinNames::BasicObject.name,
RBS::BuiltinNames::TrueClass.name,
@@ -755,12 +762,18 @@
return method_type.with(
type: method_type.type.with(
return_type: AST::Types::Logic::ArgIsReceiver.new(location: method_type.type.return_type.location)
)
)
- when RBS::BuiltinNames::Object.name, RBS::BuiltinNames::String.name, RBS::BuiltinNames::Integer.name, RBS::BuiltinNames::Symbol.name,
- RBS::BuiltinNames::TrueClass.name, RBS::BuiltinNames::FalseClass.name, TypeName("::NilClass")
+ when RBS::BuiltinNames::Object.name,
+ RBS::BuiltinNames::Kernel.name,
+ RBS::BuiltinNames::String.name,
+ RBS::BuiltinNames::Integer.name,
+ RBS::BuiltinNames::Symbol.name,
+ RBS::BuiltinNames::TrueClass.name,
+ RBS::BuiltinNames::FalseClass.name,
+ TypeName("::NilClass")
# Value based type-case works on literal types which is available for String, Integer, Symbol, TrueClass, FalseClass, and NilClass
return method_type.with(
type: method_type.type.with(
return_type: AST::Types::Logic::ArgEqualsReceiver.new(location: method_type.type.return_type.location)
)
@@ -781,5 +794,6 @@
method_type
end
end
end
end
+