# Does buildMap changes implementations in 1.6?

**URL:** <https://discuss.kotlinlang.org/t/does-buildmap-changes-implementations-in-1-6/23783>\
**Category:** Support\
**Created:** [December 28, 2021, 2:30am UTC](https://discuss.kotlinlang.org/t/does-buildmap-changes-implementations-in-1-6/23783 "2021-12-28T02:30:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smallufo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/smallufo/32/1618_2.png) [@smallufo](https://discuss.kotlinlang.org/u/smallufo)\
**Post date:** [December 28, 2021, 2:30am UTC](https://discuss.kotlinlang.org/t/does-buildmap-changes-implementations-in-1-6/23783/1 "2021-12-28T02:30:55Z")

</div>

The following code works well before 1.6

```auto
fun getMap(): Map<String, String> {
    return buildMap {
      if (A) {
        put(key, "A")
      } else {
        put(key, "B")
      }
    }
  }

```

but after upgrade to kotlin 1.6 , compiler complains type mismatch :

```auto
Type mismatch.
Required:
Unit
Found:
String
Type mismatch.
Required:
Unit
Found:
TypeVariable(V)?
Type mismatch.
Required:
Unit
Found:
String?

```

I have to change to this style :

```auto
    return buildMap {
      put(key, if (A) "A" else "B")
    }

```

It is OK but not so readable.

But why !?

---

<div class="post-metadata">

**Author:** ![smallufo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/smallufo/32/1618_2.png) [@smallufo](https://discuss.kotlinlang.org/u/smallufo)\
**Post date:** [December 28, 2021, 11:20pm UTC](https://discuss.kotlinlang.org/t/does-buildmap-changes-implementations-in-1-6/23783/2 "2021-12-28T23:20:39Z")

</div>

Oops , today I reopened IntelliJ and rollback to my original style and IDEA recognizes it again… Not sure why. 🤔 🧐 🥴 Maybe there was something wrong inside IDEA…
