pdvrieze / xmlutil

XML Serialization library for Kotlin
https://pdvrieze.github.io/xmlutil/
Apache License 2.0
377 stars 30 forks source link

The use of `ExperimentalXmlUtilApi` should not emit a compiler warning #203

Closed sschuberth closed 5 months ago

sschuberth commented 5 months ago

Currently, the opt-in of ExperimentalXmlUtilApi results in a compiler warning saying

This XML Serialization code is not stable and may be subject to binary and source incompatible changes

This makes it hard for people with a allWarningsAsErrors = true compiler setting to take the experimental API into use. Isn't the fact to explicitly opt-in to *Experimental*XmlUtilApi already enough of a sign that the user wants this, so the warning could be dropped?

pdvrieze commented 5 months ago

@sschuberth That seems weird. Did you use the @OptIn annotation on the right element? It should mute the warning (the IDE is pretty good in suggesting it, but in some cases doesn't actually target the right context)

sschuberth commented 5 months ago

Ah, there were two things: First of all, I was mislead by the warning message saying

The declaration override should be annotated with '@nl.adaptivity.xmlutil.ExperimentalXmlUtilApi' or '@OptIn(nl.adaptivity.xmlutil.ExperimentalXmlUtilApi::class)'

So I used @ExperimentalXmlUtilApi although it should have been @OptIn(ExperimentalXmlUtilApi::class). Secondly, I was indeed using the annotation on the override of the defaultOutputKind() function whereas it should have been using it on the surrounding class that derives from DefaultXmlSerializationPolicy.

Thanks for pointing me into the right direction!