Skip to content

SI-8462: Int shift Long result corrected#4238

Merged
gkossakowski merged 1 commit intoscala:2.12.xfrom
som-snytt:issue/8462
Jan 14, 2015
Merged

SI-8462: Int shift Long result corrected#4238
gkossakowski merged 1 commit intoscala:2.12.xfrom
som-snytt:issue/8462

Conversation

@som-snytt
Copy link
Contributor

Constant folding was incorrectly promoting to Long when the
operand was Long, as with other binary ops, but the result
type depends on the receiver.

Per SLS 12.2.1.

This fixes ((1 << 2L): Int) and the other shift ops.

@scala-jenkins scala-jenkins added this to the 2.12.0-M1 milestone Jan 8, 2015
@mpociecha
Copy link
Contributor

This ticket is related to all such problems with bitwise shifts - not only to integers. I mean there were problems also in the case of characters, e.g:

scala> 'c' >>> 2L
res1: Long = 24

scala> val c = 'c'
c: Char = c

scala> c >>> 2L
res2: Int = 24

On the other hand your changes already corrected also characters so, please, add also tests for them. Except this one remark it seems to look okay.

Constant folding was incorrectly promoting to Long when the
operand was Long, as with other binary ops, but the result
type depends on the receiver.

Per SLS 12.2.1.

This fixes ((1 << 2L): Int) and the other shift ops and
the other integral types.
@som-snytt
Copy link
Contributor Author

Augmented the message and test.

@mpociecha
Copy link
Contributor

LGTM

@gkossakowski
Copy link
Contributor

Thanks!

gkossakowski added a commit that referenced this pull request Jan 14, 2015
SI-8462: Int shift Long result corrected
@gkossakowski gkossakowski merged commit ac5c324 into scala:2.12.x Jan 14, 2015
@som-snytt som-snytt deleted the issue/8462 branch February 9, 2015 00:58
@adriaanm adriaanm added the 2.12 label Oct 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants