don't generate two 'flatMap' methods(*) for Iterator
* with the same erased signature #KT-3373 Fixed
This commit is contained in:
@@ -35,7 +35,7 @@ fun main(args: Array<String>) {
|
||||
buildFor(Iterators, "")
|
||||
}
|
||||
|
||||
val iteratorSignatures = templates.map { it.signature.flat() }.toSet()
|
||||
val iteratorSignatures = templates.map { it.erasedSignature.flat() }.toSet()
|
||||
templates.clear()
|
||||
|
||||
collections()
|
||||
@@ -50,15 +50,15 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
templates.writeTo(File(outDir, "_Iterables.kt")) {
|
||||
if (iteratorSignatures contains signature.flat()) "" else buildFor(Iterables, "")
|
||||
if (iteratorSignatures contains erasedSignature.flat()) "" else buildFor(Iterables, "")
|
||||
}
|
||||
|
||||
templates.writeTo(File(outDir, "_IteratorsCommon.kt")) {
|
||||
if (iteratorSignatures contains signature.flat()) "" else buildFor(Iterators, "")
|
||||
if (iteratorSignatures contains erasedSignature.flat()) "" else buildFor(Iterators, "")
|
||||
}
|
||||
|
||||
templates.writeTo(File(outDir, "_Collections.kt")) {
|
||||
if (iteratorSignatures contains signature.flat()) buildFor(Collections, "") else ""
|
||||
if (iteratorSignatures contains erasedSignature.flat()) buildFor(Collections, "") else ""
|
||||
}
|
||||
|
||||
generateDownTos(File(outDir, "_DownTo.kt"), "package kotlin")
|
||||
|
||||
@@ -179,7 +179,7 @@ fun collections() {
|
||||
}
|
||||
}
|
||||
|
||||
f("flatMap(transform: (T)-> Iterable<R>)") {
|
||||
f("flatMap(transform: (T)-> Iterable<R>)", "flatMap(Function1)") {
|
||||
doc = "Returns the result of transforming each element to one or more values which are concatenated together into a single list"
|
||||
typeParam("R")
|
||||
returns("List<R>")
|
||||
@@ -581,4 +581,4 @@ fun collections() {
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ enum class Family {
|
||||
PrimitiveArrays
|
||||
}
|
||||
|
||||
class GenericFunction(val signature : String) {
|
||||
class GenericFunction(val signature : String, val erasedSignature: String) {
|
||||
var doc : String = ""
|
||||
var toNullableT : Boolean = false
|
||||
val isInline : Boolean = true;
|
||||
@@ -151,8 +151,8 @@ fun String.trimTrailingSpaces() : String {
|
||||
|
||||
val templates = ArrayList<GenericFunction>()
|
||||
|
||||
fun f(signature : String, init : GenericFunction.() -> Unit) {
|
||||
val gf = GenericFunction(signature)
|
||||
fun f(signature : String, erasedSignature: String = signature, init : GenericFunction.() -> Unit) {
|
||||
val gf = GenericFunction(signature, erasedSignature)
|
||||
gf.init()
|
||||
templates.add(gf)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ fun iterators() {
|
||||
}
|
||||
}
|
||||
|
||||
f("flatMap(transform: (T) -> Iterator<R>)") {
|
||||
f("flatMap(transform: (T) -> Iterator<R>)", "flatMap(Function1)") {
|
||||
doc = "Returns an iterator over the concatenated results of transforming each element to one or more values"
|
||||
typeParam("R")
|
||||
returns("Iterator<R>")
|
||||
|
||||
Reference in New Issue
Block a user