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.



1208
1209
1210
# File 'lib/rbs/types.rb', line 1208

def initialize(return_type:)
  @return_type = return_type
end

Instance Attribute Details

#return_typeObject (readonly)

Returns the value of attribute return_type.



1206
1207
1208
# File 'lib/rbs/types.rb', line 1206

def return_type
  @return_type
end

Instance Method Details

#each_param(&block) ⇒ Object



1232
1233
1234
1235
1236
1237
1238
# File 'lib/rbs/types.rb', line 1232

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

#each_type(&block) ⇒ Object



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  true
end

#free_variables(acc = Set.new) ⇒ Object



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

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

#has_classish_type?Boolean

Returns:

  • (Boolean)


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

def has_classish_type?
  return_type.has_classish_type?
end

#has_self_type?Boolean

Returns:

  • (Boolean)


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

def has_self_type?
  return_type.has_self_type?
end

#map_type(&block) ⇒ Object



1216
1217
1218
1219
1220
1221
1222
# File 'lib/rbs/types.rb', line 1216

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

#param_to_sObject



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

def param_to_s
  "?"
end

#return_to_sObject



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

def return_to_s
  return_type.to_s(1)
end

#sub(subst) ⇒ Object



1246
1247
1248
# File 'lib/rbs/types.rb', line 1246

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

#to_json(state = _ = nil) ⇒ Object



1240
1241
1242
1243
1244
# File 'lib/rbs/types.rb', line 1240

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

#update(return_type: self.return_type) ⇒ Object



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

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

#with_nonreturn_voidObject



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

def with_nonreturn_void
  false
end

#with_return_type(ty) ⇒ Object



1250
1251
1252
# File 'lib/rbs/types.rb', line 1250

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