kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

SerialInfo annotation: Default parameters in custom annotation cause compiler exception

Open slava110 opened this issue 3 years ago • 2 comments
trafficstars

Describe the bug I'm using custom annotation @YamlComment annotated with @SerialInfo. If @YamlComment annotation contains default parameters compiler will throw an error

To Reproduce

@Target(AnnotationTarget.PROPERTY)
@SerialInfo
public annotation class YamlComment(
    val comment: String,
    val trimIndent: Boolean = false // Throws an error
)

Environment

  • Kotlin version: 1.6.21
  • Library version: Plugin: 1.6.21, SerializationCore: 1.3.3
  • Kotlin platforms: JVM
  • Gradle version: 7.4.2
  • Other relevant context: JDK 8 is used for project code, JDK 11 is used for Gradle

slava110 avatar May 31 '22 04:05 slava110

This specific case seems to be fixed in 1.7, but it's broken when the first parameter is vararg :/

I've opened KT-53235 on YouTrack for this issue

NightEule5 avatar Jul 19 '22 08:07 NightEule5

Hi!

As I understand it, default parameters are still not supported? I have such a case - it does not build with caches for JVM and strange problems in Kotlin/Native

https://youtrack.jetbrains.com/issue/KT-53475/KotlinNative-for-iOS-IllegalArgumentException-Sequence-has-more-than-one-element

ProVir avatar Aug 08 '22 17:08 ProVir

Seems to be fixed in the latest release (or in Kotlin 1.8.0).

sandwwraith avatar Sep 27 '22 16:09 sandwwraith