diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-08-09 13:34:05 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-08-09 13:34:05 +0200 |
commit | c13a7ce1ce8a4f37ec4f5071834cbdbe0b1446aa (patch) | |
tree | 6f975e6ef544c640b5cfbb3bda2837449bf560ee /tests/pos | |
parent | 594e8dd17b1b3c7f26a7ee979ecdf43d77a51cb1 (diff) | |
download | dotty-c13a7ce1ce8a4f37ec4f5071834cbdbe0b1446aa.tar.gz dotty-c13a7ce1ce8a4f37ec4f5071834cbdbe0b1446aa.tar.bz2 dotty-c13a7ce1ce8a4f37ec4f5071834cbdbe0b1446aa.zip |
Test that #1442 is fixed.
Diffstat (limited to 'tests/pos')
-rw-r--r-- | tests/pos/i1442.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/pos/i1442.scala b/tests/pos/i1442.scala new file mode 100644 index 000000000..abb46d3aa --- /dev/null +++ b/tests/pos/i1442.scala @@ -0,0 +1,24 @@ +object Test1442 { + final def sumMinimized[B](num: Numeric[B]): Int = { + var cse: scala.math.Numeric.type = null.asInstanceOf[scala.math.Numeric.type] + ({cse = scala.math.Numeric; num eq cse.IntIsIntegral} || + (num eq cse.DoubleAsIfIntegral)) + 2 + } + + final def sum[B](implicit num: Numeric[B]): B = { + // arithmetic series formula can be used for regular addition + var cse: scala.math.Numeric.type = null.asInstanceOf[scala.math.Numeric.type] + if ({cse = scala.math.Numeric; num eq cse.IntIsIntegral}|| + (num eq cse.BigIntIsIntegral)|| + (num eq cse.ShortIsIntegral)|| + (num eq cse.ByteIsIntegral)|| + (num eq cse.CharIsIntegral)|| + (num eq cse.LongIsIntegral)|| + (num eq cse.FloatAsIfIntegral)|| + (num eq cse.BigDecimalIsFractional)|| + (num eq cse.DoubleAsIfIntegral)) { + null.asInstanceOf[B] + } else null.asInstanceOf[B] + } +} |