Skip to content

Kotlin declarations with java reserved keywords as names results in a javapoet exception #4982

@ZacSweers

Description

@ZacSweers

This example

@Module
class ExampleModule {
  @Provides fun int(): Int = 3
}

Will crash the dagger-compiler in KSP when processing with this

not a valid name: int
java.lang.IllegalArgumentException: not a valid name: int
	at com.squareup.javapoet.Util.checkArgument(Util.java:53)
	at com.squareup.javapoet.MethodSpec$Builder.setName(MethodSpec.java:315)
	at com.squareup.javapoet.MethodSpec$Builder.<init>(MethodSpec.java:310)
	at com.squareup.javapoet.MethodSpec$Builder.<init>(MethodSpec.java:294)
	at com.squareup.javapoet.MethodSpec.methodBuilder(MethodSpec.java:188)
	at dagger.spi.internal.shaded.androidx.room.compiler.codegen.XFunSpec$Companion.builder(XFunSpec.kt:112)
	at dagger.spi.internal.shaded.androidx.room.compiler.codegen.XFunSpec$Companion.builder(XFunSpec.kt:99)
	at dagger.spi.internal.shaded.androidx.room.compiler.codegen.XFunSpec.builder(XFunSpec.kt)

Seems dagger may wanna check this name before handing it off to JP

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