Skip to content

Top-level @RenderedValue function throws ClassNotFoundException (wrong owner FQN in IR plugin) #150

Description

@paul-brooks

Symptom

A top-level (file-scope) @RenderedValue function throws ClassNotFoundException when the woven capture hook fires at runtime. Capture fails, so the value isn't recorded (and in a strict harness the test errors).

Root cause

KensaIrGenerationExtension.kt:192 computes the owner FQN passed to the hook as:
fn.parentClassOrNull?.fqNameWhenAvailable?.asString() ?: "${file.packageFqName}.${fn.name}"
For a top-level function parentClassOrNull is null, so it falls back to package.functionName — which is not a class. The runtime hook then does Class.forName(fqName) (CompilerPluginHookFunctions.kt:25) → ClassNotFoundException. The real owner is the file-facade class (<FileName>Kt).

Fix

For top-level functions, compute the file-facade class name (<FileName>Kt, honouring @JvmName) instead of package.functionName.

Top-level @RenderedValue functions currently have no test coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions