-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constant fold all the number conversion methods
Co-authored-by: Eugene Flesselle <[email protected]> Co-authored-by: Martin Kucera <[email protected]>
- Loading branch information
1 parent
ce65296
commit 7be3311
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
object Test: | ||
|
||
inline val myInt = 1 << 4 | ||
|
||
// toLong | ||
inline val byte2Long = 0.toByte.toLong | ||
inline val char2Long = 'c'.toLong | ||
inline val short2Long = 0.toShort.toLong | ||
inline val int2Long = 0.toLong | ||
inline val long2Long = 0L.toLong | ||
inline val int2LongPropagated = myInt.toLong | ||
|
||
// toInt | ||
inline val byte2Int = 0.toByte.toInt | ||
inline val char2Int = 'c'.toInt | ||
inline val short2Int = 0.toShort.toInt | ||
inline val int2Int = 0.toInt | ||
inline val long2Int = 0L.toInt | ||
inline val int2IntPropagated = myInt.toInt | ||
|
||
// toByte | ||
inline val byte2Byte = 0.toByte.toByte | ||
inline val char2Byte = 'c'.toByte | ||
inline val short2Byte = 0.toShort.toByte | ||
inline val int2Byte = 0.toByte | ||
inline val long2Byte = 0L.toByte | ||
inline val int2BytePropagated = myInt.toByte | ||
|
||
// chain everything | ||
inline val wow: Double = 1.toByte.toShort.toChar.toInt.toLong.toFloat.toDouble |