Class: RBS::Types::UntypedFunction

Inherits:
Object
  • Object
show all
Includes:
_ToJson
Defined in:
sig/types.rbs,
lib/rbs/types.rb

Overview

Function type without type checking arguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(return_type:) ⇒ UntypedFunction

Returns a new instance of UntypedFunction.

Parameters:

  • return_type: (t)


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

def initialize(return_type:)
  @return_type = return_type
end

Instance Attribute Details

#return_typet (readonly)

Returns the value of attribute return_type.

Returns:

  • (t)


1252
1253
1254
# File 'lib/rbs/types.rb', line 1252

def return_type
  @return_type
end

Instance Method Details

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

Parameters:

  • (Object)

Returns:

  • (Boolean)


1336
1337
1338
# File 'lib/rbs/types.rb', line 1336

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

#each_paramvoid #each_paramEnumerator[Function::Param, void]

Overloads:

  • #each_paramvoid

    This method returns an undefined value.

  • #each_paramEnumerator[Function::Param, void]

    Returns:

Yields:

Yield Parameters:

Yield Returns:

  • (void)


1284
1285
1286
1287
1288
1289
1290
# File 'lib/rbs/types.rb', line 1284

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

#each_typevoid #each_typeEnumerator[t, void]

Overloads:

  • #each_typevoid

    This method returns an undefined value.

  • #each_typeEnumerator[t, void]

    Returns:

    • (Enumerator[t, void])

Yields:

Yield Parameters:

  • arg0 (t)

Yield Returns:

  • (void)


1276
1277
1278
1279
1280
1281
1282
# File 'lib/rbs/types.rb', line 1276

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

#empty?Boolean

Returns:

  • (Boolean)


1312
1313
1314
# File 'lib/rbs/types.rb', line 1312

def empty?
  true
end

#free_variables(acc = Set.new) ⇒ Set[Symbol]

Parameters:

  • (Set[Symbol])

Returns:

  • (Set[Symbol])


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

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

#has_classish_type?Boolean

Returns:

  • (Boolean)


1320
1321
1322
# File 'lib/rbs/types.rb', line 1320

def has_classish_type?
  return_type.has_classish_type?
end

#has_self_type?Boolean

Returns:

  • (Boolean)


1316
1317
1318
# File 'lib/rbs/types.rb', line 1316

def has_self_type?
  return_type.has_self_type?
end

#hashInteger

Returns:

  • (Integer)


1342
1343
1344
# File 'lib/rbs/types.rb', line 1342

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

#map_typeUntypedFunction #map_typeEnumerator[t, UntypedFunction]

Overloads:

Yields:

Yield Parameters:

  • arg0 (t)

Yield Returns:

  • (t)


1262
1263
1264
1265
1266
1267
1268
# File 'lib/rbs/types.rb', line 1262

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

#map_type_name {|arg0, arg1, arg2| ... } ⇒ UntypedFunction

Yields:

Yield Parameters:

Yield Returns:

Returns:



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

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

#param_to_sString

Returns ?

Returns:

  • (String)


500
501
502
# File 'sig/types.rbs', line 500

def param_to_s
  "?"
end

#return_to_sString

Returns return_type.to_s(1)

Returns:

  • (String)


503
504
505
# File 'sig/types.rbs', line 503

def return_to_s
  return_type.to_s(1)
end

#sub(subst) ⇒ UntypedFunction

Parameters:

Returns:



1298
1299
1300
1301
1302
# File 'lib/rbs/types.rb', line 1298

def sub(subst)
  return self if subst.empty?

  map_type { _1.sub(subst) }
end

#to_json(state = nil) ⇒ Object



1292
1293
1294
1295
1296
# File 'lib/rbs/types.rb', line 1292

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

#update(return_type: self.return_type) ⇒ UntypedFunction

Parameters:

  • return_type: (t) (defaults to: self.return_type)

Returns:



1308
1309
1310
# File 'lib/rbs/types.rb', line 1308

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

#with_nonreturn_void?Boolean

Returns:

  • (Boolean)


1324
1325
1326
# File 'lib/rbs/types.rb', line 1324

def with_nonreturn_void?
  false
end

#with_return_type(ty) ⇒ UntypedFunction

Parameters:

  • (t)

Returns:



1304
1305
1306
# File 'lib/rbs/types.rb', line 1304

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