Repository navigation
THRIFT-6339: Resolve typedefs before rendering a Kotlin constant - #3938
Open
slachiewicz wants to merge 1 commit into
Open
slachiewicz wants to merge 1 commit into
slachiewicz wants to merge 1 commit into
Conversation
slachiewicz
requested review from
Jens-G,
fishy,
jimexist and
mhlakhani
as code owners
September 23, 2026 06:27
Member
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Client: kotlin generate_consts tested the declared type, so a constant of a typedef type matched neither the base-type nor the enum branch and was written without a value. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
slachiewicz
force-pushed
the
THRIFT-6339
branch
from
October 1, 2026 05:24
67c4841 to
a52488c
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The regression test does not verify the restored const modifier.
Review effort: Balanced
Findings: 1
What changed in this PR
Fixes Kotlin generation for constants declared through typedefs.
Changes:
- Resolves typedefs before rendering Kotlin constants.
- Adds regression coverage for primitive and enum typedefs.
- Enables Kotlin compiler tests by default.
| File | Description |
|---|---|
t_kotlin_generator.cc |
Resolves constant types before rendering. |
t_kotlin_generator_const_tests.cc |
Tests typedef-backed constants. |
CMakeLists.txt |
Enables Kotlin generator tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| const string generated = read_file("test_kotlin_constConstants.kt"); | ||
| REQUIRE(!generated.empty()); | ||
| REQUIRE(generated.find("val ANSWER: kotlin.Int = 42\n") != string::npos); |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

generate_conststested the declared type, so a constant declared through a typedef got neitherconstnor a value (val ANSWER: kotlin.Int =). It now resolves the typedef first, as the Java generator does.Not in this PR, and the same with or without a typedef:
uuidconstants render as0,binaryones as a string literal, and container and struct constants still get no value (the// TODObranch).Verified:
--gen kotlinover every.thriftin the repository → only the typedef constants in the twoConstantsDemo.thriftfiles change.compiler/cpp/tests/kotlin/t_kotlin_generator_const_tests.cc, which fails without the fix; kotlin generator tests are switched on.Co-Authored-By:trailer. No new dependency or third-party code.