visitSymbolLiteral method

  1. @override
Object? visitSymbolLiteral(
  1. SSymbolLiteral node
)
override

Visit a SSymbolLiteral.

Implementation

@override
Object? visitSymbolLiteral(SSymbolLiteral node) {
  // `#foo.bar.baz` is ONE library-qualified symbol named 'foo.bar.baz', not a
  // member access on `#foo`. `tom_ast_generator` already joins the analyzer's
  // component tokens with `.` into `SSymbolLiteral.value`, so this side just
  // reads the finished name. Operator symbols (`#+`, `#[]`) arrive as a single
  // component and need no special handling.
  //
  // A non-const `Symbol` is correct even though the literal is a compile-time
  // constant in real Dart: `Symbol` compares by name, so the value this builds
  // is `==` (and hash-equal) to the SDK's canonicalised `#foo`. That is what
  // lets a script mix `#foo` and `Symbol('foo')` freely, including as Map keys.
  return Symbol(node.value);
}