Skip to content

Commit

Permalink
Implement review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jul 30, 2019
1 parent 24feac1 commit f1a26bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class Typer extends Namer
inferImplicit(fromDigitsCls.typeRef.appliedTo(target), EmptyTree, tree.span) match {
case SearchSuccess(arg, _, _) =>
val fromDigits = untpd.Select(untpd.TypedSplice(arg), nme.fromDigits).withSpan(tree.span)
val firstArg = Literal(Constant(digits.toString))
val firstArg = Literal(Constant(digits))
val otherArgs = tree.kind match {
case Whole(r) if r != 10 => Literal(Constant(r)) :: Nil
case _ => Nil
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/reference/changed-features/numeric-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: doc-page
title: Numeric Literals
---

In Scala 2, numeric literals were confined to the promitive numeric types `Int`, Long`, `Float`, and `Double`. Scala 3 allows to write numeric literals also for user defined types. Example:
In Scala 2, numeric literals were confined to the primitive numeric types `Int`, Long`, `Float`, and `Double`. Scala 3 allows to write numeric literals also for user defined types. Example:
```
val x: Long = -10_000_000_000
val y: BigInt = 0x123_abc_789_def_345_678_901
Expand Down Expand Up @@ -128,7 +128,7 @@ should produce the `BigFloat` number `BigFloat(-123, 997)`:
The companion object of `BigFloat` defines an `apply` constructor method to construct a `BigFloat`
from a `digits` string. Here is a possible implementation:
```scala
object BigFloat extends App {
object BigFloat {
import scala.util.FromDigits

def apply(digits: String): BigFloat = {
Expand Down Expand Up @@ -216,7 +216,7 @@ implementation method `fromDigitsImpl`. Here is its definition:
case digits =>
'{apply($digits)}
}
}
} // end BigFloat
```
The macro implementation takes an argument of type `Expr[String]` and yields
a result of type `Expr[BigFloat]`. It tests whether its argument is a constant
Expand Down

0 comments on commit f1a26bd

Please sign in to comment.