pdvrieze/xmlutil

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

sschuberth opened this issue · 2 comments

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?

@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)

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!