Add explicit imports of kotlin.ranges more specific functions

The extensions 'contains' and 'reversed' from kotlin.ranges can be more
specific for IntRange, LongRange, etc than the same functions from
kotlin.collections, yet they lose in overload resolution to the latter
ones when invoked from kotlin.collections package
because of same package package extensions are preferred (KT-30633).
This commit is contained in:
Ilya Gorbunov
2019-03-30 04:41:52 +03:00
parent d77f76bdb0
commit 04bbf23936
16 changed files with 34 additions and 0 deletions
@@ -14,6 +14,8 @@ package kotlin.collections
//
import kotlin.random.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns 1st *element* from the collection.
@@ -14,6 +14,8 @@ package kotlin.collections
//
import kotlin.random.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns 1st *element* from the collection.
@@ -14,6 +14,8 @@ package kotlin.collections
//
import kotlin.random.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns a [List] containing all key-value pairs.
@@ -14,6 +14,8 @@ package kotlin.collections
//
import kotlin.random.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns a set containing all elements of the original set except the given [element].
@@ -15,6 +15,8 @@ package kotlin.collections
//
import kotlin.random.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns 1st *element* from the collection.
@@ -14,6 +14,8 @@ package kotlin.collections
//
import kotlin.random.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an array of UByte containing all of the elements of this collection.
@@ -13,6 +13,8 @@ package kotlin.collections
import kotlin.js.*
import primitiveArrayConcat
import withType
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
@@ -11,6 +11,8 @@ package kotlin.collections
//
import kotlin.js.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Reverses elements in the list in-place.
@@ -11,6 +11,8 @@ package kotlin.collections
//
import kotlin.js.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
@@ -13,6 +13,8 @@ package kotlin.collections
import kotlin.js.*
import primitiveArrayConcat
import withType
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
@@ -11,6 +11,8 @@ package kotlin.collections
//
import kotlin.js.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Reverses elements in the list in-place.
@@ -11,6 +11,8 @@ package kotlin.collections
//
import kotlin.js.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
@@ -13,6 +13,8 @@ package kotlin.collections
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
@@ -13,6 +13,8 @@ package kotlin.collections
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns a list containing all elements that are instances of specified class.
@@ -14,6 +14,8 @@ package kotlin.collections
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
@@ -103,6 +103,10 @@ fun List<MemberBuilder>.writeTo(file: File, targetedSource: TargetedSourceFile)
if (target.platform == Platform.Common) {
writer.appendln("import kotlin.random.*")
}
if (sourceFile.packageName == "kotlin.collections") {
writer.appendln("import kotlin.ranges.contains")
writer.appendln("import kotlin.ranges.reversed")
}
writer.appendln()