Class InvocationResolver

java.lang.Object
io.micronaut.sourcegen.model.InvocationResolver

@Internal public final class InvocationResolver extends Object
Resolves a call again where it is written, which the model cannot while the call is built: it knows neither the class the call is written in nor, for a variable named alone, the bounds that class and the method declare.
  • A method the caller does not access - a package-private one of another package, a protected one of a class the caller does not extend, or reached through a receiver that is not of the caller's class - is replaced by the one javac chooses among those it accesses.
  • A method the owner does not declare is resolved again where the model could not resolve it: on `this` or `super`, of the caller's own class, or with an argument or a receiver that names a variable alone.
  • A call no declared method is named by, which is ambiguous among those it accesses, is rejected, as javac rejects it.

A method the owner declares and the caller accesses is kept as it is, whether the model resolved it or it was given explicitly.

Since:
2.3
  • Method Details

    • resolve

      public static @Nullable InvocationResolver.Call resolve(TypeDef owner, MethodDef method, List<? extends ExpressionDef> values, Map<String,TypeDef> scope)
      Resolves a call in the scope of the class and the method it is written in, where an argument or the receiver names a variable alone.
      Parameters:
      owner - The type the method is invoked on
      method - The method as the model holds it
      values - The arguments
      scope - The variables of the class and the method, with their bounds, by name
      Returns:
      The call, or null where it is kept as it is
    • resolve

      public static @Nullable InvocationResolver.Call resolve(TypeDef owner, MethodDef method, List<? extends ExpressionDef> values, Map<String,TypeDef> scope, @Nullable ObjectDef caller, boolean self)
      Resolves a call in the scope of the class and the method it is written in, among the members the class accesses.
      Parameters:
      owner - The type the method is invoked on, `this` and `super` resolved in the definition
      method - The method as the model holds it
      values - The arguments
      scope - The variables of the class and the method, with their bounds, by name
      caller - The definition the call is written in, or null
      self - Whether the receiver is `this` or `super` - a constructor invoked by `this(...)` or `super(...)` rather than instantiated by `new`
      Returns:
      The call, or null where it is kept as it is
      Throws:
      IllegalStateException - where the call is ambiguous