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