Skip to content

Accept class, object, and property targets in FUN/FUNS (#18)#19

Merged
devcrocod merged 1 commit intomasterfrom
issue-18-widen-fun-targets
Apr 21, 2026
Merged

Accept class, object, and property targets in FUN/FUNS (#18)#19
devcrocod merged 1 commit intomasterfrom
issue-18-widen-fun-targets

Conversation

@devcrocod
Copy link
Copy Markdown
Owner

Summary

  • Restore 0.1.x behavior for non-function FUN / FUNS targets: KtNamedFunction, KtClassOrObject, and KtProperty are all valid now. Unblocks Kotlin/DataFrame's nested interface { object { … } } wrapper pattern (fixes Regression: FUN no longer resolves non-function targets (classes, objects, properties) #18).
  • Add Ambiguous FUN 'X' diagnostic with candidate FQNs for the new collision mode where a bare short name matches declarations of multiple kinds; widen FUNS zero-match message from "matched no functions" to "matched no declarations".
  • New integration fixture declarations/ covering top-level object, primary-constructor class, nested interface { object } (DataFrame's exact pattern), top-level property with getter-body markers, and a FUNS glob over sibling objects.

Test plan

  • ./gradlew build
  • ./gradlew :integration-tests:test — 9 tests pass, including new declarationsFixture()
  • Spot-check against Kotlin/DataFrame PR #1710 (HsqldbGuide.kt nested-interface pattern)

Restore 0.1.x behavior for non-function targets. 0.2.0 narrowed `<!---FUN
name-->` to `KtNamedFunction` only, which broke consumers like Kotlin/DataFrame
that point directives at an `object` / `class` / `interface` wrapper with
`//SampleStart` / `//SampleEnd` markers inside. `KtNamedFunction`,
`KtClassOrObject`, and `KtProperty` are now all valid targets; enum entries,
type aliases, local declarations, and `.kts` scripts remain unsupported.

- `FqnResolver`: widen the short-name and FQN indices from `KtNamedFunction`
  to `KtNamedDeclaration`. Index classes / objects / properties alongside
  functions (still recursing into class bodies for nested members;
  `KtEnumEntry` is explicitly skipped). Add `ambiguous()` helper that returns
  candidate FQNs when a bare short name resolves to multiple declarations.
- `SampleExtractor`: accept `KtNamedDeclaration`. Functions keep the existing
  body-with-braces-stripped behavior via the `KtDeclarationWithBody` branch;
  classes / objects / properties fall through to `buildSampleText()` so the
  existing `//SampleStart` / `//SampleEnd` marker semantics apply verbatim.
- `SamplesTransformer`: widen signatures to `KtNamedDeclaration`; expose
  `ambiguous()` as a proxy.
- `Korro.kt`: emit an "Ambiguous FUN 'X'" diagnostic with candidate FQNs when
  a bare short name is ambiguous (avoids a misleading "Cannot resolve" now
  that the index includes more kinds). Widen the FUNS zero-match message
  from "matched no functions" to "matched no declarations".
- Add `integration-tests/fixtures/declarations/` covering top-level object,
  primary-constructor class, nested `interface { object }` (the DataFrame
  pattern), top-level property with getter-body markers, and a FUNS glob
  over sibling objects. New `declarationsFixture()` test method.
- Update `CLAUDE.md`, `MIGRATION.md`, and `README.md` invariants to list the
  three supported declaration kinds.
@devcrocod devcrocod merged commit d99b3cd into master Apr 21, 2026
1 of 2 checks passed
@devcrocod devcrocod deleted the issue-18-widen-fun-targets branch April 21, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: FUN no longer resolves non-function targets (classes, objects, properties)

1 participant