Skip to content

Dart target: render IrTemplateExpression bodies so DartTemplate mappings activate #172

Description

@danfma

Context

`MapMethodAttribute` and `MapPropertyAttribute` already accept `DartTemplate` (e.g. `"$0.toLowerCase()"` / `"$this.length"`), and the frontend stores them on `DeclarativeMappingEntry`. The Dart-side BCL mapper currently honors only the rename form (`DartName`); when an entry has only `DartTemplate`, `IrToDartBclMapper.TryMapCall` falls through and emits the original C# call site untouched.

Scope

  • Reuse the existing `IrTemplateExpression` IR node (target-agnostic) when `DartTemplate` is set; build it from the registry entry inside `IrToDartBclMapper`.
  • Teach the Dart `IrBodyPrinter` to render `IrTemplateExpression` by substituting `$this`, `$0`, `$1`, … placeholders with the lowered receiver / argument expressions (mirror of the TS `TsTemplate` printer).
  • Forward `DartRuntimeImports` through to `DartImportCollector` so opaque template identifiers still pull the right `metano_runtime` show clause.
  • Add tests covering: instance template (`$this.foo()`), static template (`bar($0)`), receiver-less template, `$T0` generic-type substitution.

Why this unblocks BCL expansion

Without template rendering, anything more sophisticated than a direct method/property rename has to wait. Issue #173 (BCL surface expansion) depends on this landing first.

Part of #28

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions