Open sandboxFocusImprove this doc

LAMA0660: A redirected call was not rewritten

Severity Warning
Reported by Metalama.Framework
Message The linker could not apply <Redirection>, so the source code is kept unchanged. The call site is in a position that the linker does not rewrite, for instance the initializer of a field that an aspect has promoted to a property. Move the call to a position that the linker rewrites, for instance to a constructor.

Cause

Extensions such as Metalama.Extensions.Interceptors let an aspect or fabric redirect calls to a method to another method. The Metalama linker performs the redirection by rewriting the call in the code of the project.

The linker can't rewrite every call. When an aspect overrides a field, Metalama promotes the field to a property, and the linker doesn't find the calls in the initializer of the promoted field. Metalama then keeps the source code unchanged, so the call isn't redirected, and reports LAMA0660 on the call. In the message, <Redirection> describes the call, its new target and the aspect that requested the redirection.

The InterceptMethods method of Metalama.Extensions.Interceptors checks this situation itself and reports LAMA1012 before the linker runs, so LAMA0660 can't be shown in an example with this package. Only an extension that registers call site redirections directly with the Metalama SDK reaches this diagnostic, which is why this article has no example.

Resolution

Move the call to a position that the linker rewrites. For instance, move the call from the field initializer to the body of a constructor. Alternatively, don't override the field with an aspect.

See also