Class: RBS::Types::UntypedFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(return_type:) ⇒ UntypedFunction

Returns a new instance of UntypedFunction.



1215
1216
1217
# File 'lib/rbs/types.rb', line 1215

def initialize(return_type:)
  @return_type = return_type
end

Instance Attribute Details

#return_typeObject (readonly)

Returns the value of attribute return_type.



1213
1214
1215
# File 'lib/rbs/types.rb', line 1213

def return_type
  @return_type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



1295
1296
1297
# File 'lib/rbs/types.rb', line 1295

def ==(other)
  other.is_a?(UntypedFunction) && other.return_type == return_type
end

#each_param(&block) ⇒ Object



1245
1246
1247
1248
1249
1250
1251
# File 'lib/rbs/types.rb', line 1245

def each_param(&block)
  if block
    # noop
  else
    enum_for :each_param
  end
end

#each_type(&block) ⇒ Object



1237
1238
1239
1240
1241
1242
1243
# File 'lib/rbs/types.rb', line 1237

def each_type(&block)
  if block
    yield return_type
  else
    enum_for :each_type
  end
end

#empty?Boolean

Returns:

  • (Boolean)


1271
1272
1273
# File 'lib/rbs/types.rb', line 1271

def empty?
  true
end

#free_variables(acc = Set.new) ⇒ Object



1219
1220
1221
# File 'lib/rbs/types.rb', line 1219

def free_variables(acc = Set.new)
  return_type.free_variables(acc)
end

#has_classish_type?Boolean

Returns:

  • (Boolean)


1279
1280
1281
# File 'lib/rbs/types.rb', line 1279

def has_classish_type?
  return_type.has_classish_type?
end

#has_self_type?Boolean

Returns:

  • (Boolean)


1275
1276
1277
# File 'lib/rbs/types.rb', line 1275

def has_self_type?
  return_type.has_self_type?
end

#hashObject



1301
1302
1303
# File 'lib/rbs/types.rb', line 1301

def hash
  self.class.hash ^ return_type.hash
end

#map_type(&block) ⇒ Object



1223
1224
1225
1226
1227
1228
1229
# File 'lib/rbs/types.rb', line 1223

def map_type(&block)
  if block
    update(return_type: yield(return_type))
  else
    enum_for :map_type
  end
end

#map_type_name(&block) ⇒ Object



1231
1232
1233
1234
1235
# File 'lib/rbs/types.rb', line 1231

def map_type_name(&block)
  UntypedFunction.new(
    return_type: return_type.map_type_name(&block)
  )
end

#param_to_sObject



1287
1288
1289
# File 'lib/rbs/types.rb', line 1287

def param_to_s
  "?"
end

#return_to_sObject



1291
1292
1293
# File 'lib/rbs/types.rb', line 1291

def return_to_s
  return_type.to_s(1)
end

#sub(subst) ⇒ Object



1259
1260
1261
# File 'lib/rbs/types.rb', line 1259

def sub(subst)
  map_type { _1.sub(subst) }
end

#to_json(state = _ = nil) ⇒ Object



1253
1254
1255
1256
1257
# File 'lib/rbs/types.rb', line 1253

def to_json(state = _ = nil)
  {
    return_type: return_type
  }.to_json(state)
end

#update(return_type: self.return_type) ⇒ Object



1267
1268
1269
# File 'lib/rbs/types.rb', line 1267

def update(return_type: self.return_type)
  UntypedFunction.new(return_type: return_type)
end

#with_nonreturn_void?Boolean

Returns:

  • (Boolean)


1283
1284
1285
# File 'lib/rbs/types.rb', line 1283

def with_nonreturn_void?
  false
end

#with_return_type(ty) ⇒ Object



1263
1264
1265
# File 'lib/rbs/types.rb', line 1263

def with_return_type(ty)
  update(return_type: ty)
end