[Serialization] Suppress OPT_IN errors in all diagnostic tests

This commit is contained in:
Dmitriy Novozhilov
2022-08-25 12:48:30 +03:00
committed by teamcity
parent 84b8ab1f9c
commit a6d3c6e5c6
33 changed files with 35 additions and 50 deletions
@@ -65,8 +65,13 @@ class RegisteredDirectivesBuilder private constructor(
}
private fun <K : Directive, V> MutableMap<K, V>.putWithExistsCheck(key: K, value: V) {
val alreadyRegistered = put(key, value)
if (alreadyRegistered != null) {
val alreadyRegistered = get(key)
if (alreadyRegistered == null) {
put(key, value)
} else if (alreadyRegistered is List<Any?> && value is List<Any?>) {
@Suppress("UNCHECKED_CAST")
put(key, (alreadyRegistered + value) as V)
} else {
error("Default values for $key directive already registered")
}
}