# Kotlin 2.0.20 bug found

**URL:** https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380
**Category:** Uncategorized
**Created:** [October 9, 2024, 2:22am UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380 "2024-10-09T02:22:47Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kenny.goers](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/kenny.goers/32/10969_2.png) [@kenny.goers](https://discuss.kotlinlang.org/u/kenny.goers)
#### Post date: [October 9, 2024, 2:22am UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380/1 "2024-10-09T02:22:47Z")

</div>

I ran into a problem in 2.0.20 that I can not reproduce in 1.9.0, 1.9.10, 1.9.20 or 2.0.0

The following code won’t compile due to accessing the var “list”

class GenericClass {  
@PublishedApi internal var list = mutableListOf()

companion object {  
inline fun GenericClass.init() {  
list = mutableListOf() // compiler error accessing list, only fails for setting, not getting  
}  
}  
}

This appears to be specific to generic classes, this same code without the generic type compiles.

Thoughts? Am reporting to the right place?

---

<div class="post-metadata">

### Author: ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)
#### Post date: [October 12, 2024, 10:42am UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380/2 "2024-10-12T10:42:41Z")

</div>

The correct place to report bugs is [https://kotl.in/issue](https://kotl.in/issue)

---

<div class="post-metadata">

### Author: ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)
#### Post date: [October 12, 2024, 10:47am UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380/3 "2024-10-12T10:47:54Z")

</div>

Also, I can’t reproduce your problem. How do you call this `init` function? Could you write it in [https://play.kotlinlang.org/](https://play.kotlinlang.org/)?

---

<div class="post-metadata">

### Author: ![kenny.goers](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/kenny.goers/32/10969_2.png) [@kenny.goers](https://discuss.kotlinlang.org/u/kenny.goers)
#### Post date: [October 13, 2024, 1:20pm UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380/4 "2024-10-13T13:20:01Z")

</div>

I can post a project, I don’t call it at all, this doesn’t compile when building with 2.0.20, but it builds with 1.9 and 2.0.0

---

<div class="post-metadata">

### Author: ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)
#### Post date: [October 15, 2024, 10:33am UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380/5 "2024-10-15T10:33:28Z")

</div>

It doesn’t look like your sample code would ever compile, because you’re not providing a type parameter to `mutableListOf`. How does the compiler know what the type of `internal var list` is? Right now it’d just be `List` with no type.

---

<div class="post-metadata">

### Author: ![kyay10](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@kyay10](https://discuss.kotlinlang.org/u/kyay10)
#### Post date: [October 15, 2024, 10:46am UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380/6 "2024-10-15T10:46:16Z")

</div>

There seems to be a formatting problem due to angle brackets `<>`. I was able to get the original text of the post using Discourse’s raw API, but OP, please use code formatting using triple backticks ``` next time

```auto
class GenericClass<T> {
  @PublishedApi internal var list = mutableListOf<String>()

  companion object {
    inline fun <reified T : Any> GenericClass<T>.init() {
      list = mutableListOf() // compiler error accessing list, only fails for setting, not getting
    }
  }
}

```

I can’t seem to reproduce the compiler error though, at least on 2.0.21

---

<div class="post-metadata">

### Author: ![kenny.goers](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/kenny.goers/32/10969_2.png) [@kenny.goers](https://discuss.kotlinlang.org/u/kenny.goers)
#### Post date: [October 15, 2024, 7:02pm UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-20-bug-found/29380/7 "2024-10-15T19:02:19Z")

</div>

I just verified that is doesn’t occur in 2.0.21, just in 2.0.20 so you can consider this fixed.
