New J2K: do not print Unit types
This commit is contained in:
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.nj2k.tree.*
|
||||
import org.jetbrains.kotlin.nj2k.tree.visitors.JKVisitorWithCommentsPrinting
|
||||
import org.jetbrains.kotlin.nj2k.types.JKContextType
|
||||
import org.jetbrains.kotlin.nj2k.types.isInterface
|
||||
import org.jetbrains.kotlin.nj2k.types.isUnit
|
||||
import org.jetbrains.kotlin.nj2k.types.updateNullability
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
@@ -346,8 +347,10 @@ internal class JKCodeBuilder(context: NewJ2kConverterContext) {
|
||||
it.accept(this)
|
||||
}
|
||||
renderTokenElement(method.rightParen)
|
||||
printer.print(": ")
|
||||
method.returnType.accept(this)
|
||||
if (!method.returnType.type.isUnit()) {
|
||||
printer.print(": ")
|
||||
method.returnType.accept(this)
|
||||
}
|
||||
renderExtraTypeParametersUpperBounds(method.typeParameterList)
|
||||
method.block.accept(this)
|
||||
}
|
||||
|
||||
@@ -184,6 +184,9 @@ fun JKType.isArrayType() =
|
||||
else -> false
|
||||
}
|
||||
|
||||
fun JKType.isUnit() =
|
||||
safeAs<JKClassType>()?.classReference?.fqName == KotlinBuiltIns.FQ_NAMES.unit.asString()
|
||||
|
||||
val JKType.isCollectionType: Boolean
|
||||
get() = safeAs<JKClassType>()?.classReference?.fqName in collectionFqNames
|
||||
|
||||
|
||||
Reference in New Issue
Block a user