stdlib-gen: allow template function sequences
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,9 @@ abstract class TemplateGroupBase : TemplateGroup {
|
||||
it.returnType.isSubtypeOf(typeIterableOfMemberTemplates) ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
yieldAll(it.call(this) as Iterable<MemberTemplate>)
|
||||
it.returnType.isSubtypeOf(typeSequenceOfMemberTemplates) ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
yieldAll(it.call(this) as Sequence<MemberTemplate>)
|
||||
else ->
|
||||
error("Member $it violates naming convention")
|
||||
}
|
||||
@@ -44,6 +47,7 @@ abstract class TemplateGroupBase : TemplateGroup {
|
||||
companion object {
|
||||
private val typeMemberTemplate = MemberTemplate::class.createType()
|
||||
private val typeIterableOfMemberTemplates = Iterable::class.createType(arguments = listOf(KTypeProjection.invariant(typeMemberTemplate)))
|
||||
private val typeSequenceOfMemberTemplates = Sequence::class.createType(arguments = listOf(KTypeProjection.invariant(typeMemberTemplate)))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user