Skip to content

[KSP] Intersection type bounds are not ordered correctly in generated factories #4345

Closed
@ZacSweers

Description

@ZacSweers

Given this snippet in Kotlin

abstract class Other

class InjectClass<T> @Inject constructor(
  private val t: T
) where T : Appendable, T : Other

Dagger generates a factory in KSP like so

public final class InjectClass_Factory<T extends Appendable & Other> implements Factory<InjectClass<T>> {
  // ...
}

This code however doesn't compile, because while Kotlin allows for the class bound to be in any order, Java requires it to be the first type. That is to say, the generated code should actually be.

public final class InjectClass_Factory<T extends Other & Appendable> implements Factory<InjectClass<T>> {
  // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions