-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prepare for Dotty #406
prepare for Dotty #406
Conversation
@@ -123,7 +123,7 @@ abstract class Quantity[A <: Quantity[A]] extends Serializable with Ordered[A] { | |||
* @return Quantity | |||
*/ | |||
def negate: A = unit(-value) | |||
def unary_-(): A = negate | |||
def unary_- : A = negate |
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.
This looks like it should be a binary-compatible change. If unary_-
had an empty parameter lists, Dotty would prevent you from calling it as -x
.
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.
I was planning to put this as a separate PR to be included in the current master. This triggers warnings on 2.13.3
@@ -171,7 +171,7 @@ abstract class Quantity[A <: Quantity[A]] extends Serializable with Ordered[A] { | |||
* @return | |||
*/ | |||
override def equals(that: Any) = that match { | |||
case x: Quantity[A] if x.dimension == dimension ⇒ value == x.to(unit) | |||
case x: Quantity[_] if x.dimension == dimension ⇒ value == x.asInstanceOf[Quantity[A]].to(unit) |
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.
Dotty prohibits this type assertion (Scala 2 should warn about this). I'm not entirely sure if my "fix" is correct.
@@ -144,7 +144,7 @@ case class DoubleVector(coordinates: Double*) extends SVector[Double] { | |||
|
|||
type SVectorType = DoubleVector | |||
|
|||
def magnitude: Double = math.sqrt(coordinates.toTraversable.map(v ⇒ v * v).sum) | |||
def magnitude: Double = math.sqrt(coordinates.map(v ⇒ v * v).sum) |
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.
Most of the collection conversions here seemed redundant to me, so I deleted them.
@@ -3,7 +3,7 @@ package squants.motion | |||
import squants.mass.MomentOfInertia | |||
import squants.space._ | |||
import squants.time.{Seconds, Time, TimeDerivative} | |||
import squants.{AbstractQuantityNumeric, Dimension, Length, PrimaryUnit, Quantity, SiUnit, UnitConverter, UnitOfMeasure} | |||
import squants.{AbstractQuantityNumeric, Dimension, Length, PrimaryUnit, Quantity, SiUnit, SquantifiedDouble, UnitConverter, UnitOfMeasure} |
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.
SquantifiedDouble
is an implicit class that triggers somewhere in this file and I'm surprised that it compiled under Scala 2 (it needs to be in scope).
Tests prove to be difficult. I have another branch where I'm down to 126 errors, but I'm keeping it on hold because it's with an old version of Dotty (0.24). I'd rather wait for ScalaTest to come out for 0.26. |
How did you verify this compiles in dotty? |
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.
Thanks looks great
I have patched the build definition to include the
|
I've verified that
squantsJVM
builds with Dotty 0.26.0-RC1 (tests still pending).