Change signed to unsigned widening conversions to sign-extending
e.g. `Byte.toUInt()` now returns `UInt.MAX_VALUE` for Byte value of -1 instead of 0xFFu. #KT-26594 Fixed
This commit is contained in:
@@ -199,7 +199,11 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
for (otherType in UnsignedType.values()) {
|
||||
val name = otherType.capitalized
|
||||
out.print(" public fun to$name(): $name = ")
|
||||
out.println(if (type == otherType) "this" else "data.to${otherType.capitalized}()")
|
||||
out.println(when {
|
||||
otherType > type -> "data.to${otherType.capitalized}() and ${type.mask}u"
|
||||
otherType == type -> "this"
|
||||
else -> "data.to${otherType.capitalized}()"
|
||||
})
|
||||
}
|
||||
out.println()
|
||||
}
|
||||
@@ -212,7 +216,6 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
out.println("@ExperimentalUnsignedTypes")
|
||||
out.print("public fun $otherSigned.to$className(): $className = ")
|
||||
out.println(when {
|
||||
otherType < type -> "$className(this.to$thisSigned() and ${otherType.mask})"
|
||||
otherType == type -> "$className(this)"
|
||||
else -> "$className(this.to$thisSigned())"
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user