Class: Mirah::JVM::Types::NarrowingType
- Inherits:
-
Object
- Object
- Mirah::JVM::Types::NarrowingType
- Defined in:
- lib/mirah/jvm/types/literals.rb
Overview
Represents a literal number that can be represented in multiple types
Direct Known Subclasses
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(default_type, narrowed_type) ⇒ NarrowingType
constructor
A new instance of NarrowingType.
-
#narrow! ⇒ Object
Changes this type to the smallest type that will hold its literal value.
Constructor Details
#initialize(default_type, narrowed_type) ⇒ NarrowingType
Returns a new instance of NarrowingType.
23 24 25 26 |
# File 'lib/mirah/jvm/types/literals.rb', line 23 def initialize(default_type, narrowed_type) super(default_type) @narrowed = default_type != narrowed_type && narrowed_type end |
Instance Method Details
#hash ⇒ Object
28 29 30 |
# File 'lib/mirah/jvm/types/literals.rb', line 28 def hash __getobj__.hash end |
#narrow! ⇒ Object
Changes this type to the smallest type that will hold its literal value.
34 35 36 37 38 39 |
# File 'lib/mirah/jvm/types/literals.rb', line 34 def narrow! if @narrowed __setobj__(@narrowed) true end end |