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

K2 compiler crashes Detekt #6715

Open
jarroyoesp opened this issue Dec 13, 2023 · 16 comments · May be fixed by #6640
Open

K2 compiler crashes Detekt #6715

jarroyoesp opened this issue Dec 13, 2023 · 16 comments · May be fixed by #6640
Assignees

Comments

@jarroyoesp
Copy link

Expected Behavior

After updating our project to use K2 compiler we expect we don't get a crash when we run detekt

Observed Behavior

In our project when we run detekt we are getting similar exceptions to this one:

> Exception while analyzing expression in (135,15) in //Forlago/modules/feature-foo/src/main/kotlin/com/leinardi/forlago/feature/foo/ui/foo/FooScreen.kt

  Attachments:
  causeThrowable
  java.lang.IllegalArgumentException: fromIndex(1) > toIndex(0)
        at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509)
        at java.base/java.util.ArrayList.subList(ArrayList.java:1108)
        at org.jetbrains.kotlin.builtins.FunctionTypesKt.getValueParameterTypesFromFunctionType(functionTypes.kt:178)
....

Steps to Reproduce

  1. Update your project to use K2 compiler. To achieve that you have to update your gradle.properties file adding:
# K2
android.experimental.lint.version=8.3.0-alpha17
android.lint.useK2Uast=true
kapt.use.k2=true
kotlin.experimental.tryK2=true
  1. Run detekt and we are getting several exceptions similar to:
> Task :modules:feature-debug:detektDebug FAILED
ERROR: Exception while analyzing expression in (200,11) in //Users/javierarroyo/Projects/Personal/Forlago/modules/feature-debug/src/main/kotlin/com/leinardi/forlago/feature/debug/ui/DebugScreen.kt

Attachments:
causeThrowable
java.lang.IllegalArgumentException: fromIndex(1) > toIndex(0)
        at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509)
        at java.base/java.util.ArrayList.subList(ArrayList.java:1108)
        at org.jetbrains.kotlin.builtins.FunctionTypesKt.getValueParameterTypesFromFunctionType(functionTypes.kt:178)
        at org.jetbrains.kotlin.resolve.FunctionDescriptorResolver.getValueParameters(FunctionDescriptorResolver.kt:380)

Github example

You can find a project sample with the issue here:

Your Environment

  • Version of detekt used: 1.23.4
  • Version of Gradle used (if applicable): 8.5
  • Gradle scan link (add --scan option when running the gradle task):
  • Operating System and version: Mac OS Monterey - v12.7.1
  • Link to your project (if it's a public repository): Task: Use K2 compiler leinardi/Forlago#48
@jarroyoesp jarroyoesp added the bug label Dec 13, 2023
@3flex
Copy link
Member

3flex commented Dec 13, 2023

It would help if you could test against this branch please: #6640

detekt is not currently compatible with K2 compiler.

@jarroyoesp
Copy link
Author

jarroyoesp commented Dec 15, 2023

Hey @3flex, thanks for the info, but one thing, we would like to test your branch prepared for K2, but how could we import your changes in our project?

@3flex
Copy link
Member

3flex commented Dec 15, 2023

https://docs.gradle.org/current/userguide/composite_builds.html

Good luck! Sorry I can't provide time to support getting it set up but it should be relatively simple. You'll need to separately include the Gradle plugin and the rest of the project.

@jarroyoesp
Copy link
Author

Ok, I'll try next week 👍 thanks!

@jarroyoesp

This comment has been minimized.

@3flex

This comment has been minimized.

@jarroyoesp jarroyoesp linked a pull request Dec 20, 2023 that will close this issue
@3flex 3flex pinned this issue Jan 4, 2024
@3flex 3flex self-assigned this Feb 9, 2024
@3flex 3flex added the core label Feb 10, 2024
@mgroth0

This comment has been minimized.

@mgroth0

This comment has been minimized.

@3flex

This comment has been minimized.

@mgroth0

This comment has been minimized.

@mgroth0

This comment has been minimized.

@3flex

This comment has been minimized.

@mgroth0

This comment has been minimized.

@3flex

This comment has been minimized.

@mgroth0

This comment has been minimized.

@mgroth0

This comment has been minimized.

@3flex 3flex unpinned this issue Apr 6, 2024
@3flex 3flex pinned this issue Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants