Skip to content

Add support for Kotlin 2.2.0#155

Open
orangain wants to merge 15 commits intomainfrom
kotlin-2.2.0
Open

Add support for Kotlin 2.2.0#155
orangain wants to merge 15 commits intomainfrom
kotlin-2.2.0

Conversation

@orangain
Copy link
Owner

@orangain orangain commented Jul 20, 2025

This includes:

  • Support for annotation target @all
  • Support for parsing intersection type
  • Support for context parameters
    • Node.ContextReceiver has moved to Node.Modifier.ContextReceiver
  • Support for multi-dollar string interpolation
    • StringLiteralExpression.raw and TemplateStringEntry.short is now read-only.

Release note of Kotlin 2.2.0: https://kotlinlang.org/docs/whatsnew22.html

@ov7a
Copy link
Contributor

ov7a commented Jul 21, 2025

Hey, @orangain, can you also take a look at #144, please?

@orangain orangain requested a review from Copilot August 10, 2025 06:35

This comment was marked as outdated.

@orangain orangain requested a review from Copilot August 10, 2025 08:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for Kotlin 2.2.0 by implementing several new language features including annotation target @all, intersection types, context parameters, and multi-dollar string interpolation. The changes also refactor the context receiver implementation to be organized under modifiers.

  • Context receivers moved from Node.ContextReceiver to Node.Modifier.ContextReceiver
  • String literal expressions refactored to support multi-dollar prefixes with computed raw and suffix properties
  • Added support for intersection types and context parameters as new AST node types

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ast/src/commonMain/kotlin/ktast/ast/Node.kt Core AST node definitions updated with new types and refactored string/context handling
ast/src/commonMain/kotlin/ktast/builder/Builders.kt Builder functions updated to match new API signatures and node structure
ast/src/commonMain/kotlin/ktast/ast/Writer.kt Writer implementation updated for new node types and string formatting
ast/src/commonMain/kotlin/ktast/ast/Visitor.kt Visitor pattern updated to handle new node types and moved context receivers
ast/src/commonMain/kotlin/ktast/ast/MutableVisitor.kt Mutable visitor updated to handle new node types and moved context receivers
ast/src/commonMain/kotlin/ktast/ast/Dumper.kt Dumper updated to show new string literal properties
ast/src/commonTest/kotlin/ktast/ast/NodeTest.kt New test file added to validate string literal behavior
ast/build.gradle.kts Test dependencies configuration added
ast-psi/src/main/kotlin/ktast/ast/psi/Converter.kt PSI converter updated to handle new Kotlin 2.2.0 syntax
ast-psi/src/main/kotlin/ktast/ast/psi/PsiExtensions.kt Helper extension added for string template processing
ast-psi/src/test/kotlin/ktast/ast/psi/CorpusParseAndWriteWithExtrasTest.kt Error assertion temporarily commented out
ast-psi/src/test/kotlin/ktast/ast/psi/CorpusParseAndWriteHeuristicTest.kt Error assertion temporarily commented out
.github/workflows/java_ci.yaml CI updated to test against Kotlin 2.2.0 instead of 2.0.21

override val supplement: NodeSupplement = NodeSupplement(),
) : StringEntry {
init {
require(!short || expression is NameExpression || expression is ThisExpression) {
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

The validation logic references the short property but it's now a computed property that depends on prefix.endsWith("{"). This validation should be updated to use the prefix directly: require(!prefix.endsWith("{") || expression is NameExpression || expression is ThisExpression)

Suggested change
require(!short || expression is NameExpression || expression is ThisExpression) {
require(!prefix.endsWith("{") || expression is NameExpression || expression is ThisExpression) {

Copilot uses AI. Check for mistakes.
@@ -47,7 +47,7 @@ class CorpusParseAndWriteWithExtrasTest(private val unit: Corpus.Unit) {
}
} catch (e: Parser.ParseError) {
if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

This assertion is commented out, which may indicate incomplete work or temporary debugging. Consider either removing this code entirely or adding a TODO comment explaining why it's disabled and when it should be re-enabled.

Suggested change
if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e
if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e
// TODO: Re-enable the assertion below when partial parsing is supported.

Copilot uses AI. Check for mistakes.
@@ -49,7 +49,7 @@ class CorpusParseAndWriteHeuristicTest(private val unit: Corpus.Unit) {
}
} catch (e: Parser.ParseError) {
if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

This assertion is commented out, which may indicate incomplete work or temporary debugging. Consider either removing this code entirely or adding a TODO comment explaining why it's disabled and when it should be re-enabled.

Suggested change
if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e
if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e
// TODO: Enable the following assertion when partial parsing and error reporting are fully supported.

Copilot uses AI. Check for mistakes.
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.

3 participants