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)


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

def initialize(return_type:)
  @return_type = return_type
end

Instance Attribute Details

#return_typet (readonly)

Returns the value of attribute return_type.

Returns:

  • (t)


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

def return_type
  @return_type
end

Instance Method Details

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

Parameters:

  • (Object)

Returns:

  • (Boolean)


1378
1379
1380
# File 'lib/rbs/types.rb', line 1378

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)


1326
1327
1328
1329
1330
1331
1332
# File 'lib/rbs/types.rb', line 1326

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)


1318
1319
1320
1321
1322
1323
1324
# File 'lib/rbs/types.rb', line 1318

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

#empty?Boolean

Returns:

  • (Boolean)


1354
1355
1356
# File 'lib/rbs/types.rb', line 1354

def empty?
  true
end

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

Parameters:

  • (Set[Symbol])

Returns:

  • (Set[Symbol])


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

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

#has_classish_type?Boolean

Returns:

  • (Boolean)


1362
1363
1364
# File 'lib/rbs/types.rb', line 1362

def has_classish_type?
  return_type.has_classish_type?
end

#has_self_type?Boolean

Returns:

  • (Boolean)


1358
1359
1360
# File 'lib/rbs/types.rb', line 1358

def has_self_type?
  return_type.has_self_type?
end

#hashInteger

Returns:

  • (Integer)


1384
1385
1386
# File 'lib/rbs/types.rb', line 1384

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

#map_typeUntypedFunction #map_typeEnumerator[t, UntypedFunction]

Overloads:

Yields:

Yield Parameters:

  • arg0 (t)

Yield Returns:

  • (t)


1304
1305
1306
1307
1308
1309
1310
# File 'lib/rbs/types.rb', line 1304

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:



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

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

#param_to_sString

Returns ?

Returns:

  • (String)


510
511
512
# File 'sig/types.rbs', line 510

def param_to_s
  "?"
end

#return_to_sString

Returns return_type.to_s(1)

Returns:

  • (String)


513
514
515
# File 'sig/types.rbs', line 513

def return_to_s
  return_type.to_s(1)
end

#sub(subst) ⇒ UntypedFunction

Parameters:

Returns:



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

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

  map_type { _1.sub(subst) }
end

#to_json(state = nil) ⇒ Object



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

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:



1350
1351
1352
# File 'lib/rbs/types.rb', line 1350

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

#with_nonreturn_void?Boolean

Returns:

  • (Boolean)


1366
1367
1368
# File 'lib/rbs/types.rb', line 1366

def with_nonreturn_void?
  false
end

#with_return_type(ty) ⇒ UntypedFunction

Parameters:

  • (t)

Returns:



1346
1347
1348
# File 'lib/rbs/types.rb', line 1346

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