@@ -18,14 +18,17 @@ internal abstract class AbstractImmutableMap<K, out V> protected constructor(pro
18
18
19
19
20
20
// should it be immutable set/collection or just read-only?
21
- private var keysWrapped: ImmutableSet <K >? = null
22
- override val keys: ImmutableSet <K > get() = keysWrapped ? : ImmutableSetWrapper (impl.keys).apply { keysWrapped = this }
21
+ private var _keys : Set <K >? = null
22
+ final override val keys: Set <K > get() = _keys ? : createKeys().apply { _keys = this }
23
+ protected open fun createKeys (): Set <K > = impl.keys
23
24
24
- private var valuesWrapped: ImmutableCollection <V >? = null
25
- override val values: ImmutableCollection <V > get() = valuesWrapped ? : ImmutableCollectionWrapper (impl.values).apply { valuesWrapped = this }
25
+ private var _values : Collection <V >? = null
26
+ final override val values: Collection <V > get() = _values ? : createValues().apply { _values = this }
27
+ protected open fun createValues (): Collection <V > = impl.values
26
28
27
- private var entriesWrapped: ImmutableSet <Map .Entry <K , V >>? = null
28
- override val entries: ImmutableSet <Map .Entry <K , V >> get() = entriesWrapped ? : ImmutableSetWrapper (impl.entries).apply { entriesWrapped = this }
29
+ private var _entries : Set <Map .Entry <K , V >>? = null
30
+ final override val entries: Set <Map .Entry <K , V >> get() = _entries ? : createEntries().apply { _entries = this }
31
+ protected open fun createEntries (): Set <Map .Entry <K , V >> = impl.entries
29
32
30
33
override fun put (key : K , value : @UnsafeVariance V ): ImmutableMap <K , V > = wrap(impl.plus(key, value))
31
34
override fun putAll (m : Map <out K , @UnsafeVariance V >): ImmutableMap <K , V > = wrap(impl.plusAll(m))
@@ -139,8 +142,8 @@ internal abstract class AbstractImmutableMap<K, out V> protected constructor(pro
139
142
}
140
143
}
141
144
142
- private fun <K , V > PMap <K , V >.contains (key : K , value : @UnsafeVariance V ): Boolean
143
- = this [key]?.let { candidate -> candidate == value } ? : (containsKey(key) && value == null )
145
+ internal fun <K , V > PMap <K , V >.contains (key : K , value : @UnsafeVariance V ): Boolean
146
+ = this [key]?.let { candidate -> candidate == value } ? : (value == null && containsKey(key) )
144
147
145
148
146
149
0 commit comments