| Severity | Error |
| Reported by | Metalama.Extensions.Interceptors |
| Message | The <Source> cannot intercept uses of members of '<Type>' because this type does not exist in the current compilation. |
Cause
Metalama.Extensions.Interceptors lets an aspect or a fabric replace the calls to selected methods, in the source code of the current project, with calls to other methods. An aspect or fabric registers an interceptor with the InterceptMethods method of its adviser, builder, or amender. The declaration on which you call this method is the interception scope: only the calls located inside this declaration are intercepted.
When you select the intercepted methods with Type( typeof(X) ).Methods( ... ), Metalama stores a durable reference to the type X and resolves it again in the compilation in which the interceptor is applied. Metalama reports LAMA1003 when this reference can't be resolved because the type doesn't exist in that compilation. In the message, <Source> describes the aspect or fabric, and <Type> identifies the type.
This diagnostic is a defensive check: for the types that the code model returns, the reference normally resolves, so you can't reproduce it with a regular example. A type introduced by an aspect is reported with LAMA1004 instead. For this reason, this article has no example.
Resolution
- Make sure that the type passed to the
Typemethod is declared in the current project or in one of its references. - Don't select a type that another aspect or a previous compilation step removes or replaces.
- If the diagnostic persists with a valid type, report it to the Metalama team, with the code of the aspect or fabric.