get method

  1. @override
Object? get(
  1. String propertyName, [
  2. InterpreterVisitor? visitor
])
override

Get a property (field or getter) on this extension type instance

Implementation

@override
Object? get(String propertyName, [InterpreterVisitor? visitor]) {
  // Check if accessing the representation field
  if (propertyName == extensionType.representationFieldName) {
    return representationValue;
  }

  // Check for getters defined on the extension type
  final getter = extensionType.getters[propertyName];
  if (getter != null && visitor != null) {
    // G-DOV3-1 FIX: Bind 'this' to the extension type instance, then call with empty args
    // Getters take no arguments - they access 'this' via the bound environment
    return getter.bind(this).call(visitor, [], {});
  }

  // Check for methods defined on the extension type
  final method = extensionType.methods[propertyName];
  if (method != null) {
    // Return the bound method for later invocation
    return method.bind(this);
  }

  throw RuntimeD4rtException(
      "Extension type '${extensionType.name}' has no property '$propertyName'");
}