Skip to content

THRIFT-6339: Resolve typedefs before rendering a Kotlin constant - #3938

Open
slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:THRIFT-6339
Open

slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:THRIFT-6339

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

generate_consts tested the declared type, so a constant declared through a typedef got neither const nor 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: uuid constants render as 0, binary ones as a string literal, and container and struct constants still get no value (the // TODO branch).

Verified: --gen kotlin over every .thrift in the repository → only the typedef constants in the two ConstantsDemo.thrift files change.

  • Did you create an Apache Jira ticket? THRIFT-6339
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit?
  • Did you do your best to avoid breaking changes? No: the affected files did not compile.
  • Code change, so the commit carries no CI-skip marker.
  • Tests: compiler/cpp/tests/kotlin/t_kotlin_generator_const_tests.cc, which fails without the fix; kotlin generator tests are switched on.
  • AI-assisted: the commit carries a Co-Authored-By: trailer. No new dependency or third-party code.

@mergeable mergeable Bot added kotlin compiler build and general CI cmake, automake and build system changes labels Sep 23, 2026
@Jens-G

Jens-G commented Sep 26, 2026

Copy link
Copy Markdown
Member

Code review

No 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>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 05:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The regression test does not verify the restored const modifier.

Review effort: Balanced
Findings: 1 Medium severity

Open (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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build and general CI cmake, automake and build system changes compiler kotlin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants