Interface KotlinParameterElement

All Superinterfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Element, MutableAnnotationMetadataDelegate<Element>, Named, ParameterElement, TypedElement

public interface KotlinParameterElement extends ParameterElement
Represents a Kotlin parameter to a method or constructor.

Implementing this interface additionally signals that defaulted parameters follow Kotlin's calling convention: a defaults bitmask plus the synthetic $default overload. It is therefore not a general marker for optional parameters — use ParameterElement.hasDefault() for that, and io.micronaut.inject.writer.ParameterDefaultValueProvider for languages that evaluate the default in the caller.

Since:
4.1.0
Author:
Denis Stepanov
  • Method Details

    • hasDefault

      boolean hasDefault()
      Description copied from interface: ParameterElement
      Whether the parameter declares a default value in the source language, and is therefore optional at the call site.

      This reports only that a default exists. How the value is obtained is language specific and is deliberately not part of this contract:

      • some languages evaluate the default in the caller, in which case the language module may contribute an io.micronaut.inject.writer.ParameterDefaultValueProvider to supply it;
      • others evaluate it in the callee and require a dedicated calling convention, as KotlinParameterElement does.
      Specified by:
      hasDefault in interface ParameterElement
      Returns:
      True if the parameter has a default value