Conversation
Parser error differs between v1.9.25 and 2.2.0.
Now TemplateStringEntry.short is read-only property.
There was a problem hiding this comment.
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.ContextReceivertoNode.Modifier.ContextReceiver - String literal expressions refactored to support multi-dollar prefixes with computed
rawandsuffixproperties - 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) { |
There was a problem hiding this comment.
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)
| require(!short || expression is NameExpression || expression is ThisExpression) { | |
| require(!prefix.endsWith("{") || expression is NameExpression || expression is ThisExpression) { |
| @@ -47,7 +47,7 @@ class CorpusParseAndWriteWithExtrasTest(private val unit: Corpus.Unit) { | |||
| } | |||
| } catch (e: Parser.ParseError) { | |||
| if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e | |||
There was a problem hiding this comment.
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.
| 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. |
| @@ -49,7 +49,7 @@ class CorpusParseAndWriteHeuristicTest(private val unit: Corpus.Unit) { | |||
| } | |||
| } catch (e: Parser.ParseError) { | |||
| if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e | |||
There was a problem hiding this comment.
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.
| 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. |
This includes:
@allNode.ContextReceiverhas moved toNode.Modifier.ContextReceiverStringLiteralExpression.rawandTemplateStringEntry.shortis now read-only.Release note of Kotlin 2.2.0: https://kotlinlang.org/docs/whatsnew22.html