Class: Steep::AST::Types::Nil

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/ast/types/nil.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location: nil) ⇒ Nil

Returns a new instance of Nil.



7
8
9
# File 'lib/steep/ast/types/nil.rb', line 7

def initialize(location: nil)
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



5
6
7
# File 'lib/steep/ast/types/nil.rb', line 5

def location
  @location
end

Instance Method Details

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



11
12
13
# File 'lib/steep/ast/types/nil.rb', line 11

def ==(other)
  other.is_a?(Nil)
end

#back_typeObject



41
42
43
44
45
# File 'lib/steep/ast/types/nil.rb', line 41

def back_type
  Name::Instance.new(name: Builtin::NilClass.module_name,
                     args: [],
                     location: location)
end

#free_variablesObject



29
30
31
# File 'lib/steep/ast/types/nil.rb', line 29

def free_variables
  Set.new
end

#hashObject



15
16
17
# File 'lib/steep/ast/types/nil.rb', line 15

def hash
  self.class.hash
end

#levelObject



33
34
35
# File 'lib/steep/ast/types/nil.rb', line 33

def level
  [0]
end

#subst(s) ⇒ Object



21
22
23
# File 'lib/steep/ast/types/nil.rb', line 21

def subst(s)
  self
end

#to_sObject



25
26
27
# File 'lib/steep/ast/types/nil.rb', line 25

def to_s
  "nil"
end

#with_location(new_location) ⇒ Object



37
38
39
# File 'lib/steep/ast/types/nil.rb', line 37

def with_location(new_location)
  self.class.new(location: new_location)
end