diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt index cb26432824d..c278e500d97 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt @@ -405,7 +405,7 @@ class StubGenerator( out("var ${field.name.asSimpleName()}: $kotlinType") - val signed = field.type.getUnderlyingIntegerType().isSigned + val signed = field.type.isIntegerTypeSigned() val readBitsExpr = "readBits(this.rawPtr, ${field.offset}, ${field.size}, $signed).${rawType.convertor!!}()" @@ -422,10 +422,11 @@ class StubGenerator( } } - private tailrec fun Type.getUnderlyingIntegerType(): IntegerType = when (this) { - is IntegerType -> this - is EnumType -> this.def.baseType.getUnderlyingIntegerType() - is Typedef -> this.def.aliased.getUnderlyingIntegerType() + private tailrec fun Type.isIntegerTypeSigned(): Boolean = when (this) { + is IntegerType -> this.isSigned + is BoolType -> false + is EnumType -> this.def.baseType.isIntegerTypeSigned() + is Typedef -> this.def.aliased.isIntegerTypeSigned() else -> error(this) }