Class: Rigor::TypeNode::Identifier
- Inherits:
-
Object
- Object
- Rigor::TypeNode::Identifier
- Defined in:
- lib/rigor/type_node/identifier.rb
Overview
A bare named-type reference in an RBS::Extended payload. The name is the head as the parser
saw it — kebab-case for built-in refinement names ("non-empty-string"), PascalCase for
class-like names ("String", "Pick"), lower_snake for type-function-shaped names without
arguments (rare).
The resolver dispatch path treats an Identifier as the no-arg form: if a plugin recognises
Pick as a TS-utility name, it MAY still return Dynamic[top] for the bare Identifier("Pick")
since TypeScript's Pick is only meaningful with two type arguments. The Generic carrier is
what plugin resolvers normally key on.
Instance Method Summary collapse
-
#initialize(name:) ⇒ Identifier
constructor
A new instance of Identifier.
Constructor Details
#initialize(name:) ⇒ Identifier
Returns a new instance of Identifier.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rigor/type_node/identifier.rb', line 15 def initialize(name:) unless name.is_a?(String) && !name.empty? raise ArgumentError, "TypeNode::Identifier name must be a non-empty String, " \ "got #{name.inspect}" end # Freeze the String field so the resulting Data object is `Ractor.shareable?` regardless of # whether the caller passed a `# frozen_string_literal: true` constant or a dynamically built # String. The same discipline applies to every other TypeNode value object — they live in the # parser's hot path and are the natural carriers to flow through future Ractor boundaries # (see CURRENT_WORK Open Items #8). super(name: name.frozen? ? name : name.dup.freeze) end |