← 输入框|github.com|刷新
Skip to content

build: bump kotlin to 2.3.21 and silence DSL marker warning - #355

Merged
beanbag44 merged 5 commits into
lambda-client:1.21.11from
blocksimus:kotlin-2.3.21
Oct 28, 2026
Merged

beanbag44 merged 5 commits into
lambda-client:1.21.11from
blocksimus:kotlin-2.3.21

Conversation

@blocksimus

Copy link
Copy Markdown
Contributor

Description

This is mainly quality of life, getting rid of heaps of warnings in newer IntelliJ versions. It warns about every DSL marker we put on a function. We do it on purpose for the IDE colors... JetBrains says to suppress it (KT-83668). The warning only exists from Kotlin 2.3.20, so we need the bump before we can turn it off.

And... the bump changed how context overloads get picked (KT-82579), so the nullable runSafeAutomated is now runSafeAutomatedOrNull.

Context overloads no longer win over plain ones, so
the nullable runSafeAutomated gets its own name.
@beanbag44
beanbag44 self-requested a review October 24, 2026 17:18

@beanbag44 beanbag44 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good but im confused about the runSafeAutomatedOrNull change. Its nullable because the SafeContext could return null but then for consistency runSafe() should also be runSafeOrNull and i feel like thats way too verbose

@beanbag44

Copy link
Copy Markdown
Member

oops, meant runSafeAutomatedOrNull, not runAutomatedSafeContextOrNull

@blocksimus

blocksimus commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Yea the naming is a bit weird... I could rename the context one to runAutomated, because it already has a safe context... and the other stays runSafeAutomated, like runSafe.

Made this change ... it touches more files, but I think makes more sense.

It already has a safe context, so runSafeAutomated goes back
to being the nullable one, like runSafe.
@blocksimus
blocksimus requested a review from beanbag44 October 25, 2026 02:48
@beanbag44

Copy link
Copy Markdown
Member

Im not sure the reason for changing naming? I think the original names worked fine because they described the function explicitly. Calling runAutomated would give the impression that youre creating a new Automated scope but what its really doing is combining SafeContext and Automated

@blocksimus

Copy link
Copy Markdown
Contributor Author

Sorry, I could have been clearer about the why... It's not that the names were bad, it was a change in the way Kotlin resolves method overloads after the version bump (KT-82579). So calls in the code that previously used runSafeAutomated inside the existing SafeContext suddenly started using the one that creates a new SafeContext or null. And it can change without you realising, unless the result has to be non-null.

e.g. EatTask.onStart does reason = runSafeAutomated { reasonEating() }. On 2.3.21 that picks the nullable one and fails (actual type is EatConfig.Reason?).

Without renaming, you could write runSafeAutomated(automated = this) {} at every call to get the context one.

So the main options are:

  • Rename one of the methods to avoid the overload
  • Keep the naming and update all the callers to include automated = this
  • Use Kotlin's internal @LowPriorityInOverloadResolution on the nullable one. It brings back the old behaviour with no caller changes, but it's unsupported: it needs a @Suppress("INVISIBLE_REFERENCE"), and the compiler warns that may stop working.

@beanbag44

Copy link
Copy Markdown
Member

oof, thats really annoying. I thought it could have been a compiler change but when i reverted the name back to see if there were any issues it didnt show any linting errors. I suppose i just didnt check the call sites.

@beanbag44

beanbag44 commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

How about withSafeAutomated? runSafeAutomated is generating and running a new SafeContext, and withSafeAutomated is just combining the two contexts you already have

It joins the SafeContext and Automated already in scope, where
runSafeAutomated makes a new SafeContext.
@beanbag44
beanbag44 merged commit 9445930 into lambda-client:1.21.11 Oct 28, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Kanban Oct 28, 2026
@blocksimus
blocksimus deleted the kotlin-2.3.21 branch October 30, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants