Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KSP2] Deprecated annotation causes KSValidateVisitor to invalidate everything #2099

Open
DHuijkman opened this issue Sep 12, 2024 · 0 comments

Comments

@DHuijkman
Copy link

kotlin version: 2.0.20
KSP version: 2.0.20-1.0.25

When i run my processor and validate symbols found with the following code:

val xmlToComposeSymbols = resolver.getSymbolsWithAnnotation(ComposeConverter::class.qualifiedName!!)
val composeToXmlSymbols = resolver.getSymbolsWithAnnotation(XmlConverter::class.qualifiedName!!)

val unProcessed = (xmlToComposeSymbols + composeToXmlSymbols).filter { !it.validate() }.toList()

unprocessed always contains whatever classes i annotated with my own annotation ComposeConverter (the other line about XmlConverter can be ignored for now.

It seems since the most recent version that every time it validates the KSAnnotated object and the class annotated with ComposeConverter contains something using the annotation Deprecated, it won't pass validation. I made a testing class in the following:

@ComposeConverter
class TestView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    @AttrRes defStyleAttr: Int = R.attr.tpaAmountViewStyle,
) : androidx.appcompat.widget.AppCompatTextView(context, attrs, defStyleAttr) {

    private data class AmountViewState(...)

    private fun updateAmount() {...}

    private var state = AmountViewState()
        set(value) {
            field = value
            updateAmount()
        }

//    region Deprecated Properties
    @Deprecated("")
    var amount: Float = 0.00f
        set(amount) {
            field = amount
            moneyValue = amount.toBigDecimal()
        }
    //region Public Properties
    /**
     * The amount that will be displayed.
     * */
    var moneyValue: BigDecimal = BigDecimal.ZERO
        set(moneyValue) {
            field = moneyValue
            state = state.copy(moneyValue = moneyValue)
        }
        get() = state.moneyValue
}

When my processor sees this it will not pass the validation and wont do anything with it. Now if i take the same class but comment out the Deprecated annotation it passes the validation fine. Even if i replace it with an annotation of my own it is fine.

Is this a bug or is there a setting/config i have to change to make it work with this annotation?

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

No branches or pull requests

1 participant