Does buildMap changes implementations in 1.6?

The following code works well before 1.6

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 :

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 :

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

It is OK but not so readable.

But why !?

Oops , today I reopened IntelliJ and rollback to my original style and IDEA recognizes it again… Not sure why. :thinking: :face_with_monocle: :woozy_face: Maybe there was something wrong inside IDEA…