-
Notifications
You must be signed in to change notification settings - Fork 19
No implicit widening conversions ... #30
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ trait Constants extends api.Constants { | |
def isCharRange: Boolean = isIntRange && Char.MinValue <= intValue && intValue <= Char.MaxValue | ||
def isIntRange: Boolean = ByteTag <= tag && tag <= IntTag | ||
def isLongRange: Boolean = ByteTag <= tag && tag <= LongTag | ||
def isFloatRange: Boolean = ByteTag <= tag && tag <= FloatTag | ||
def isDoubleRange: Boolean= FloatTag == tag || tag == DoubleTag | ||
def isNumeric: Boolean = ByteTag <= tag && tag <= DoubleTag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain what's going on here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is saying that only floats and doubles fit in doubles, instead of all the numeric types. Then it renames the method. Before there wasn't an "isDoubleRange" because in the context this was being used, that was always true. And afterward I suppose there's no "isFloatRange" because it would only be true for floats and thus never checked. |
||
def isNonUnitAnyVal = BooleanTag <= tag && tag <= DoubleTag | ||
def isAnyVal = UnitTag <= tag && tag <= DoubleTag | ||
|
@@ -190,9 +190,7 @@ trait Constants extends api.Constants { | |
Constant(intValue) | ||
else if (target == LongClass && isLongRange) | ||
Constant(longValue) | ||
else if (target == FloatClass && isFloatRange) | ||
Constant(floatValue) | ||
else if (target == DoubleClass && isNumeric) | ||
else if (target == DoubleClass && isDoubleRange) | ||
Constant(doubleValue) | ||
else | ||
null | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,8 +53,8 @@ trait Definitions extends api.StandardDefinitions { | |
tpnme.Short -> 4, | ||
tpnme.Int -> 12, | ||
tpnme.Long -> 24, | ||
tpnme.Float -> 48, | ||
tpnme.Double -> 96 | ||
tpnme.Float -> 7, | ||
tpnme.Double -> 35 | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As "diffs that would make you leave the party" go that has to be up way up there. Replace magic numbers 48 and 96 with 7 and 35. And... voila! It's an encoding of the weak conformance relation. If B % A == 0 then A weak_<:< B. In the case of Float, all the integral types were factors of 48, and afterward none of them are factors of 7. Could have been 5. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably for efficiency. Then we stash them in a Map ... oh! wait! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case the efficiency is martin and the map is me, and it effectively reflects our different priorities. |
||
|
||
private val nameToTag = Map[Name, Char]( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice comment paulp.