Skip to content

Changelog

All notable changes to this project will be documented here.

The format follows Keep a Changelog, and this project adheres to Semantic Versioning.

[0.4.4]

Changed

  • Woven advice calls are no longer wrapped in an extra block. @Before calls are placed directly at the start of the function body, the @Around advice call is returned directly, and the @After call is the finally expression itself. The generated bytecode is unchanged; the debug report dumps show the calls without the { // BLOCK } wrapper.

[0.4.3]

Added

  • Debug reports. aspectk { debug = true } writes, per compilation, the advice that applies to each target annotation and where it came from (local, external, carried-forward), the hints that no longer resolve, and a Kotlin-like dump of every woven file with the advice on each of its functions. Reports are kept per file, so incremental builds keep the results of files they did not recompile. See Debug Reports.
  • Compiler diagnostics for aspect declarations. An @Aspect declared as a class, advice with the wrong parameter or @Around return type, and advice outside an @Aspect are now reported by the compiler frontend. IntelliJ IDEA and Android Studio can highlight them while editing. See IDE Support.
  • Build diagnostics for advice on unsuitable targets. @Around advice whose suspend modifier does not match its target, @Around on an inline function with inline or crossinline lambda parameters, and @After/@Around on a tailrec function are reported during the build. A function that fails one of the errors is not woven.

Changed

  • Every AspectK diagnostic message starts with [AspectK].

[0.4.2]

Fixed

  • Aspects from other modules did not reach Android modules whose variants have no namesake in the aspect's module. An application module with product flavors (playDebug, internalDebug, ...) compiled without the aspects of the library modules it depends on, so nothing was woven and no error was reported. Hints now travel as a variant of each module's apiElements, and Gradle's variant matching picks the right one.
  • An aspect added, changed or removed in the same module went unnoticed under AGP 9's built-in Kotlin. Incremental builds kept the previous weaving until a clean build. Change detection now reads the sources of the compile task itself.

Changed

  • Aspects follow the compile classpath. A module receives the aspects of the modules it can see at compile time. An aspect behind an implementation dependency of another module is no longer delivered; expose it with api where it has to reach further.
  • The sample builds with AGP 9 and has a flavored application module.

[0.4.1]

Added

  • Kotlin 2.4.20 support. Supported Kotlin range is now 2.2.20 ~ 2.4.20 (see the compatibility table). The plugin no longer rejects a project on 2.4.20 at configuration time.
  • Lambda targets and external target annotations are documented and tested. A target annotation can be written on a lambda or an anonymous function, including a lambda passed to an inline function when the annotation has SOURCE retention, and it can be an annotation you did not declare: from the standard library, a third-party library, or Java. Both already worked; they are now covered by tests on JVM, JS, Wasm and Native. See Target Annotations.

Fixed

  • @Around on a suspend function returning Unit could throw ClassCastException. When the last statement of the function was a suspend call that suspended and returned a value (for example a DataStore edit { }), proceed() returned that value instead of Unit and the function failed with ... cannot be cast to kotlin.Unit. JVM only.

[0.4.0]

Added

  • Several advices on one function. Every @After and @Around that applies to a function now runs; before, only the last one did. Advices are ordered by kind (@Before, then @Around, then the body, then @After), then by the order the target annotations are written on the function. See Advice Ordering for the rules and for what is not guaranteed.
  • proceedAs<T>() returns the result of proceed() cast to T.
  • proceedWith("name" to value) proceeds with only the named arguments replaced.
  • getAnnotationArgs<T>() returns the arguments of an annotation on the intercepted function by parameter name. See Extension Functions.

Changed

  • A function with several @After or @Around advices behaves differently. Code that relied on only the last advice running will now see all of them run.
  • The order of advices no longer depends on the names of the target annotations. For a function carrying several target annotations, it follows the order they are written in.
  • The Kotlin/Native, JS and Wasm libraries of aspectk-runtime have a new internal name (io.github.mole-labs:aspectk-runtime, was aspectk:aspectk-runtime). Maven coordinates are unchanged and JVM and Android are not affected. On the other targets, a library built against an older AspectK may not link against this runtime; rebuild it with 0.4.0.

Fixed

  • Android unit tests could not be compiled in a module applying the plugin. The build failed with a circular dependency on compileDebugUnitTestKotlinAndroid.

[0.3.2]

Changed

  • @After and @Around now wrap the target body in place. @After wraps the body in try { ... } finally { ... } where it stands, and @Around moves it into the proceed listener lambda. The generated $<name> local function is gone. See @After and @Around for the generated shape.
  • @After and @Around on a tailrec function now run once per recursive call.

Fixed

  • @After and @Around on inline functions. Reified type parameters, inline lambda parameters and non-local returns used to fail at compile time or get lost. An inline lambda parameter is not a value, so it shows up as null in JoinPoint.args.
  • Generic return types in MethodSignature. A return type that is a type parameter now resolves to its upper bound (Any for an unbounded T), the same way parameter types do.
  • inherits = true across interfaces and modules. Overrides of an annotated interface function, or of a function declared in another module, were skipped.
  • Aspects in main now reach test. Hints from associated compilations were not passed along, so an aspect declared in a module's main source set was not injected into its tests.
  • Stale hints. Removing @Aspect from a class, or deleting an advice function, left the old entry in hints.json and it kept being applied on later builds.
  • Incremental builds across modules. A changed aspect in an upstream module now recompiles the downstream modules that depend on it. Deleting an unrelated file, or removing an aspect together with its targets, no longer forces a full recompile.

[0.3.1]

Fixed

  • @Before/@After now weave correctly into suspend functions whose body actually suspends (e.g. calls delay) — the generated local wrapper function is now declared suspend when the target is, matching the target's continuation.

Added

  • @Around on suspend functions, via a new SuspendProceedingJoinPoint — advice can be declared suspend and call proceed() to resume the suspending target body.

[0.3.0]

Added

  • Cross-module weaving. An @Aspect declared in one module now correctly weaves into targets in a different, downstream module that depends on it — no configuration needed beyond applying the plugin to both modules. Works transitively through any dependency depth, including diamond-shaped graphs, and a module that never uses AspectK doesn't need the plugin applied at all, even sitting between two participating modules.
  • Kotlin 2.4.0 / 2.4.10 support, via a new aspectk-core-compat:compat-2400 module. Supported Kotlin range is now 2.2.20 ~ 2.4.10 (see the compatibility table).
  • AspectK no longer requires the Android Gradle Plugin on the classpath — applying it to a plain (non-Android) Kotlin Multiplatform module now works correctly.

Fixed

  • Incremental-build correctness. Real (non-clean) Gradle builds could previously miss re-weaving in three cases, all now fixed:
    • Editing only a target file (aspect file untouched) could leave the target unwoven if the aspect's file wasn't part of that incremental round.
    • Editing only an aspect file (target file untouched) could leave a stale target unwoven, since Kotlin's own incremental compiler wouldn't recompile it — a full recompile is now forced only when a file that actually changed declares or drops aspect content.
    • Cross-module hints only propagated one dependency hop; a target reachable only transitively (e.g. through a diamond) could miss the aspect's hints entirely.

[0.2.2]

Fixed

  • @Around on functions with complex bodies now compiles correctly — the IR deep-copy of the local function body was performed statement-by-statement, giving each call its own SymbolRemapper. References between local variables (e.g. val b = a + 1) were left pointing to the outer function's symbols, which the JVM lowering phase misidentified as closure captures. Once the outer body was cleared the missing frame slot caused IllegalStateException: No mapping for symbol at codegen. The entire body is now deep-copied in a single pass so all intra-body references are correctly remapped. (#AroundLocalFunctionGenerationTest)

  • @Around on functions containing lambdas or nested local functions no longer returns wrong values — BodyTransformer.visitReturn previously redirected every IrReturn to the generated $<name> local function, including returns inside nested lambdas and local functions. This caused constructs such as listOf(1,2,3).sumOf { it + base } to short-circuit after the first element. The transformer now only redirects returns that originally targeted the outer function.

Added

  • Extension functions on JoinPoint (JoinPointExtensions.kt):

    • getArg<T>(name) — retrieves a named argument, cast to T; throws on missing name
    • getArgOrNull<T>(name) — same as above but returns null on missing name or cast failure
    • getTarget<T>() — casts target to T; throws on null or cast failure
    • getTargetOrNull<T>() — casts target to T; returns null otherwise
    • findAnnotation<T>() — finds AnnotationInfo by annotation type on the intercepted function
  • Extension functions on MethodSignature (MethodSignatureExtensions.kt):

    • findAnnotation<T>() — finds AnnotationInfo by annotation type in annotations
  • Extension functions on AnnotationInfo (AnnotationInfoExtensions.kt):

    • getArg<T>(paramName) — retrieves a named annotation argument, cast to T
    • getArgOrNull<T>(paramName) — same but returns null on missing name or cast failure

[0.2.0]

Added

  • @After advice annotation: runs after the target function body in a finally block, regardless of whether an exception was thrown
  • @Around advice annotation: replaces the target function call; the original body is invoked via ProceedingJoinPoint.proceed()
  • ProceedingJoinPoint interface with proceed() and proceed(vararg args) for argument substitution
  • DefaultProceedingJoinPoint runtime implementation generated at each @Around call site

Changed

  • Advice generation pipeline restructured: each AspectContext is now dispatched directly to its generator, eliminating redundant internal lookups

[0.1.1]

Added

  • Kotlin version validation: AspectK now throws a GradleException at configuration time if the project's Kotlin compiler version is not in the supported range

Changed

  • Kotlin version updated to 2.3.10
  • pluginId in AspectKCompilerPluginRegistrar now references BuildConfig.COMPILER_PLUGIN_ID instead of a hardcoded string

[0.1.0] — Initial Release

Added

  • @Aspect annotation to mark aspect classes
  • @Before advice annotation with target and inherits parameters
  • JoinPoint interface with target, signature, and args
  • MethodSignature with full compile-time metadata
  • MethodParameter with type, name, annotations, and nullability info
  • AnnotationInfo for runtime-accessible annotation metadata
  • Kotlin Multiplatform support (JVM, JS, WASM, Native Tier 1–3)
  • K2 IR-based compiler plugin (AspectKCompilerPluginRegistrar)
  • Gradle plugin (io.github.mole-labs.aspectk.compiler)
  • Many-to-many aspect-to-target relationships
  • Inheritance support via inherits = true
  • Thread-safe AspectLookUp implementation