AGENTS.md
compiler/fir/analysis-tests/AGENTS.mdAGENTS.md
Quality
74/100
Scores the file, not the repository.Length
998 words
11 headings · 1 code blocksRepository
53k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# FIR Analysis Tests23Location: `compiler/testData/diagnostics`45## Test File Format (`.kt` files)67### Header Directives89Comment lines at the top of the file control test behavior:1011| Directive | Description |12|-----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|13| `// RUN_PIPELINE_TILL: FRONTEND`, `BACKEND` or `FIR2IR` | How far the compiler pipeline runs (FRONTEND = FIR resolution only, BACKEND = through codegen, FIR2IR = rarely once IR has been created, but failing at backend) |14| `// ISSUE: KT-XXXXX` | References a YouTrack issue |15| `// WITH_STDLIB` | Include stdlib in test classpath |16| `// LANGUAGE: +FeatureName` / `// LANGUAGE: -FeatureName` | Enable/disable language features |17| `// DIAGNOSTICS: -DIAGNOSTIC_NAME` | Suppress specific diagnostics |18| `// RENDER_DIAGNOSTICS_FULL_TEXT` | Produces `.fir.diag.txt` with human-readable error messages |19| `// RENDER_DIAGNOSTIC_ARGUMENTS` | Renders arguments inside markers, e.g. `<!TYPE_MISMATCH("A; B")!>` |20| `// DUMP_CFG` / `// DUMP_CFG: FLOW` | Generates `.dot` file with control flow graph |21| `// DUMP_INFERENCE_LOGS: option1, option2` | Possible options: FIXATION, MARKDOWN, MERMAID |22| `// CHECK_TYPE` | Enables `checkType { _<Type>() }` pattern for type assertions |23| `// FILE: Name.kt` / `// FILE: Name.java` | Multi-file test (splits single `.kt` file into virtual files) |24| `// LATEST_LV_DIFFERENCE` | Indicates test expectations differ between stable and latest language version (see `.latestLV.kt` below) |2526### Inline Diagnostic Markers2728Diagnostic assertions are placed inline around the code that should produce them:2930- `<!DIAGNOSTIC_NAME!>code<!>` — asserts `code` produces that diagnostic31- `<!DIAGNOSTIC_NAME("arg1; arg2")!>code<!>` — with diagnostic arguments (needs `RENDER_DIAGNOSTIC_ARGUMENTS`)32- `<!DIAG1, DIAG2!>code<!>` — multiple diagnostics on same code span3334### Debug Info Markers3536- `<!DEBUG_INFO_CALL("fqName: ...; typeCall: ...")!>call<!>` — asserts call resolution target37- `<!DEBUG_INFO_EXPRESSION_TYPE("type")!>expr<!>` — asserts expression type3839### Footer4041- `/* GENERATED_FIR_TAGS: tag1, tag2, ... */` — auto-generated tags listing FIR constructs present in the file; do not hand-edit4243## Associated Files (auto-generated, not hand-edited)4445| Extension | Content | Generated when |46|------------------|---------------------------------------------------------------------|---------------------------------------------------|47| `.fir.txt` | FIR tree dump (resolved FIR with `R\|...\|` references) | Only when `FIR_DUMP` directive is present |48| `.fir.diag.txt` | Diagnostics in text format (`/file.kt:(offset): severity: message`) | `RENDER_DIAGNOSTICS_FULL_TEXT` directive present |49| `.dot` | Control flow graph in Graphviz format | `DUMP_CFG` directive present |50| `.fixation.txt` | Type variable fixation process | `DUMP_INFERENCE_LOGS: FIXATION` directive present |51| `.inference.md` | General type inference logs | `DUMP_INFERENCE_LOGS: MARKDOWN` directive present |52| `.inference.mmd` | General type inference logs via Mermaid format | `DUMP_INFERENCE_LOGS: MERMAID` directive present |53| `.latestLV.kt` | Test expectations for latest language version when they differ from stable | `LATEST_LV_DIFFERENCE` directive present |5455## Latest Language Version Differences5657When a language feature has `sinceVersion` set to a future Kotlin version (e.g., `KOTLIN_2_5`), it is disabled at the stable language version but enabled at the latest language version. This causes different compiler behavior depending on which LV the test runs with.5859To handle this:601. Add `// LATEST_LV_DIFFERENCE` directive to the `.kt` test file612. Create a `.latestLV.kt` file (for diagnostics tests: `.fir.latestLV.kt` if only FIR behavior differs) containing the full test with diagnostic expectations for the latest LV623. The base `.kt` file keeps expectations for the stable (default) language version6364The latest-LV test runners (`FirLightTreeDiagnosticsWithLatestLanguageVersionTestGenerated`, `FirLightTreeOldFrontendDiagnosticsWithLatestLanguageVersionTestGenerated`) use the `.latestLV.kt` file instead of the base `.kt` file.6566Run with `-Pkotlin.test.update.test.data=true` to auto-generate/update `.latestLV.kt` content.6768## Creating a New Test69701. **Create the `.kt` test file** with appropriate directives and test code.712. **Regenerate test runners**: `./gradlew generateTests` — updates `*Generated.java` files to include the new test method.723. **Run the test once** (it will fail):73```bash74 ./gradlew :compiler:fir:analysis-tests:test --tests "org.jetbrains.kotlin.test.runners.PhasedJvmDiagnosticLightTreeTestGenerated\$Resolve\$Problems.testMyTest"75```76 This first run auto-generates the `GENERATED_FIR_TAGS` footer in the `.kt` file. No special flags are needed — tags are written automatically on first run.774. **Run the test again** — it should now pass.7879### Important notes8081- **`RUN_PIPELINE_TILL` must match actual test needs.** If the test has no expected diagnostics/errors, the framework requires `BACKEND`. Using `FRONTEND` when `BACKEND` is possible causes a "Phase FRONTEND could be promoted to BACKEND" failure.82- **`GENERATED_FIR_TAGS` are written automatically** on the first test run when absent. Do not add them manually. Just run the test, let it fail and write the tags, then run again.83- **`.fir.txt` is NOT generated by default.** It requires a `// FIR_DUMP` directive. Most tests (especially simple regression tests) do not need it.84- **stdlib is not available by default.** Functions like `println` will produce `UNRESOLVED_REFERENCE` without the `// WITH_STDLIB` directive.85- **`-Pkotlin.test.update.test.data=true`** updates handler-generated files (like `.fir.txt`) but does NOT update the `.kt` source file itself (tags, diagnostic markers). The `.kt` file is updated by the test framework's own `TagsGeneratorChecker` on a normal test run.8687## Directory Structure at `testData/resolve/`8889Root level contains individual `.kt` test files with their `.fir.txt` dumps. Subdirectories group tests by topic:9091- `annotations/`, `arguments/`, `arrays/` — basic language constructs92- `builtins/`, `stdlib/` — standard library interactions93- `callResolution/` — call resolution scenarios (overloads, invoke, SAM, operators)94- `cfa/`, `cfg/` — control flow analysis and graphs95- `checkers/`, `extraCheckers/`, `diagnostics/` — diagnostic-focused tests96- `collectionLiterals/`, `constructors/`, `constVal/` — specific constructs97- `contextParameters/`, `contextSensitiveResolutionUsingExpectedType/` — context-dependent resolution98- `contracts/` — Kotlin contracts99- `delegates/`, `destructuring/` — delegation and destructuring100- `exhaustiveness/` — exhaustive when/sealed checks101- `expresssions/` (note: misspelled in repo), `fromBuilder/` — expression-level tests102- `headerMode/` — header/expect declarations103- `inference/` — type inference104- `inlineClasses/`, `innerClasses/`, `localClasses/` — class variants105- `j+k/` — Java-Kotlin interop106- `multifile/` — multi-file tests (using `// FILE:` directive)107- `multiplatform/` — multiplatform expect/actual108- `nestedTypeAliases/`, `typeArguments/`, `typeParameters/`, `types/` — type system109- `overloadResolution/`, `overrides/` — overloading and overriding110- `problems/` — regression/bug scenarios111- `properties/`, `propertyVsField/` — property resolution112- `qualifiers/`, `references/` — qualified access and references113- `returnInExpressionBodies/` — return in expression body functions114- `samConstructors/`, `samConversions/` — SAM conversion tests115- `scopes/`, `visibility/` — scoping and visibility116- `scripts/` — Kotlin scripting117- `smartcasts/` — smart cast tests118- `suppress/` — @Suppress annotation tests119- `unqualifiedEnum/` — unqualified enum access120- `vfir/` — virtual FIR tests121- `withAllowedKotlinPackage/` — tests allowing kotlin package122
Also in JetBrains/kotlin
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| JetBrains/kotlincompiler/AGENTS.md · 53k | AGENTS.md | buildtestgit | 52/100 | 3 days ago | |
| JetBrains/kotlincompiler/build-tools/AGENTS.md · 53k | AGENTS.md | buildteststylearch+2 | 89/100 | 3 days ago | |
| JetBrains/kotlinCLAUDE.md · 53k | CLAUDE.md | agent-behaviour | 25/100 | 3 days ago | |
| JetBrains/kotlinanalysis/AGENTS.md · 53k | AGENTS.md | teststylearchapi+1 | 86/100 | 3 days ago | |
| JetBrains/kotlinanalysis/test-data-manager/AGENTS.md · 53k | AGENTS.md | teststylearchagent-behaviour | 66/100 | 3 days ago | |
| JetBrains/kotlincompiler/psi/AGENTS.md · 53k | AGENTS.md | teststylearchtesting-strategy+3 | 81/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| elastic/elasticsearchx-pack/plugin/inference/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+3 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 3 days ago | |
| react/react-nativepackages/react-native-compatibility-check/AGENTS.md · 126k | AGENTS.md | testlint-formatstylearch+4 | 99/100 | 3 days ago | |
| kurikomi-labs/komi-storeAGENTS.md · 17k | AGENTS.md | buildlint-formatstylearch+1 | 97/100 | 3 days ago | |
| tiann/KernelSUAGENTS.md · 18k | AGENTS.md | setupbuildlint-formatstyle+4 | 97/100 | 3 days ago | |
| elastic/elasticsearchAGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+6 | 96/100 | 3 days ago | |
| alibaba/nacosAGENTS.md · 33k | AGENTS.md | buildtestlint-formatstyle+6 | 96/100 | 3 days ago | |
| ktorio/ktorAGENTS.md · 14k | AGENTS.md | buildlint-formatstylearch+7 | 96/100 | 3 days ago |
