diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/JavadocStyleHtmlDoclet.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/JavadocStyleHtmlDoclet.kt
index 1beb4cf3375..fcdd37103f1 100644
--- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/JavadocStyleHtmlDoclet.kt
+++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/JavadocStyleHtmlDoclet.kt
@@ -51,8 +51,8 @@ class JavadocStyleHtmlDoclet() : Doclet {
classes.addAll(pmap.keySet())
for (c in classes) {
if (c != null) {
- val functions = map.get(c).notNull()
- val properties = pmap.get(c).notNull()
+ val functions = map.get(c).orEmpty()
+ val properties = pmap.get(c).orEmpty()
run("${p.nameAsPath}/${c.nameAsPath}-extensions.html",
ClassExtensionsTemplate(model, p, c, functions, properties))
}
diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt
index ff9ae34c4a3..a5da59318e6 100644
--- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt
+++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt
@@ -78,7 +78,7 @@ abstract class KDocTemplate() : TextTemplate() {
if ((cname.startsWith("jet.Function") || cname.startsWith("jet.ExtensionFunction")) && arguments.notEmpty()) {
val rt = arguments.last()
// TODO use drop()
- val rest = arguments.subList(0, arguments.size - 1).notNull()
+ val rest = arguments.subList(0, arguments.size - 1).orEmpty()
"${typeArguments(rest, "(", ")", "()")} -> ${link(rt)}"
} else if (cname.startsWith("jet.Tuple")) {
if (arguments.isEmpty()) {
diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt
index fc8353e2798..c7808e5e4ff 100644
--- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt
+++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt
@@ -45,7 +45,7 @@ fun inheritedExtensionFunctions(functions: Collection): Map>()
for (c in map.keySet()) {
- val allFunctions = map.get(c).notNull().toSortedSet()
+ val allFunctions = map.get(c).orEmpty().toSortedSet()
answer.put(c, allFunctions)
val des = c.descendants()
for (b in des) {
@@ -73,7 +73,7 @@ fun inheritedExtensionProperties(properties: Collection): Map>()
for (c in map.keySet()) {
- val allProperties = map.get(c).notNull().toSortedSet()
+ val allProperties = map.get(c).orEmpty().toSortedSet()
answer.put(c, allProperties)
val des = c.descendants()
for (b in des) {
diff --git a/stdlib/ktSrc/JavaUtil.kt b/stdlib/ktSrc/JavaUtil.kt
index cdad00345e8..9fb67df26f2 100644
--- a/stdlib/ktSrc/JavaUtil.kt
+++ b/stdlib/ktSrc/JavaUtil.kt
@@ -54,12 +54,12 @@ inline fun > List.sort(comparator: java.util.Co
return this
}
-/** Converts the nullable List into an empty List if its null */
-inline fun java.util.List?.notNull() : java.util.List
+/** Returns the List if its not null otherwise returns the empty list */
+inline fun java.util.List?.orEmpty() : java.util.List
= if (this != null) this else Collections.EMPTY_LIST as java.util.List
-/** Converts the nullable Set into an empty Set if its null */
-inline fun java.util.Set?.notNull() : java.util.Set
+/** Returns the Set if its not null otherwise returns the empty set */
+inline fun java.util.Set?.orEmpty() : java.util.Set
= if (this != null) this else Collections.EMPTY_SET as java.util.Set
/**
@@ -99,7 +99,7 @@ val List.last : T?
/** Returns true if the collection is not empty */
inline fun java.util.Collection.notEmpty() : Boolean = !this.isEmpty()
-/** Converts the nullable collection into an empty collection if its null */
-inline fun java.util.Collection?.notNull() : Collection
+/** Returns the Collection if its not null otherwise it returns the empty list */
+inline fun java.util.Collection?.orEmpty() : Collection
= if (this != null) this else Collections.EMPTY_LIST as Collection
diff --git a/stdlib/ktSrc/JavaUtilMap.kt b/stdlib/ktSrc/JavaUtilMap.kt
index 7768c4cc50f..4ef04bddf6f 100644
--- a/stdlib/ktSrc/JavaUtilMap.kt
+++ b/stdlib/ktSrc/JavaUtilMap.kt
@@ -20,8 +20,8 @@ val JMap<*,*>.empty : Boolean
/** Provides [] access to maps */
fun JMap.set(key : K, value : V) = this.put(key, value)
-/** Converts the nullable Map into an empty Map if its null */
-inline fun java.util.Map?.notNull() : java.util.Map
+/** Returns the Mao if its not null otherwise it returns the empty Map */
+inline fun java.util.Map?.orEmpty() : java.util.Map
= if (this != null) this else Collections.EMPTY_MAP as java.util.Map