autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

Nested generic types not detected

Open
#1,583 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
2.2k
Forks
158
Avg merge
16h 25m
Merged PRs (30d)
46

Description

**Plugin version**

Latest 3.3.0

**Gradle version**
9.1.0

**JDK version**
25

**(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version**
2.2.21

**(Optional) `reason` output for bugs relating to incorrect advice**
```
./gradlew :app:reason --id ":lib"

> Task :app:reason

------------------------------------------------------------
You asked about the dependency ':lib'.
You have been advised to change this dependency to 'implementation' from 'api'.
------------------------------------------------------------

[...]

Source: main
------------
* Uses 1 class: com.example.lib.LibBox (implies implementation).
```

**Describe the bug**
I would expect all nested generic types to be retained, not only the first level.

**To Reproduce**

```kotlin
// lib/LibBox.kt
class LibBox(val data: T)
```

```kotlin
// app/main.kt

// Another local generic box type
class Box(val data: T)

// This is OK --> api(projects.lib)
val foo: LibBox = LibBox(Unit)

// This is KO --> You have been advised to change this dependency to 'implementation' from 'api'
val foo: Box> = Box(LibBox(Unit))
```

Link to a reproducer project: https://github.com/SimonMarquis/DAGP-1583

Generic support was initially implemented here: #723

Contributor guide

Open the contributing guide

Research direction

Start by running the linked DAGP-1583 reproducer and the :app:reason task, comparing the direct LibBox case with the nested Box> case. Read the generic support introduced in #723 and trace how the reason output retains type information. Done means nested generic types are retained and the dependency advice reflects the nested usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.