From be0a844430a8e0cd124b08d51d8178ad1b368f4a Mon Sep 17 00:00:00 2001 From: Jarrod Brockman Date: Thu, 20 Oct 2016 21:27:52 +0200 Subject: [PATCH 1/4] add -Xfatal-warnings to tut script --- scripts/run-tut.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/run-tut.sh b/scripts/run-tut.sh index ad51ea6260..c9fafcc4e5 100755 --- a/scripts/run-tut.sh +++ b/scripts/run-tut.sh @@ -2,5 +2,4 @@ COURSIER_CLASSPATH="$(./coursier fetch -p com.chuusai:shapeless_2.11:2.3.1 org.scala-lang.modules::scala-xml:1.0.3)" -./coursier launch -r "https://dl.bintray.com/tpolecat/maven/" org.tpolecat:tut-core_2.11:0.4.4 -- . tut-tmp '.*\.md$' -classpath "$COURSIER_CLASSPATH" - +./coursier launch -r "https://dl.bintray.com/tpolecat/maven/" org.tpolecat:tut-core_2.11:0.4.4 -- . tut-tmp '.*\.md$' -classpath "$COURSIER_CLASSPATH" -Xfatal-warnings From 3259cc004419809575c0e6f5e302309e55a157ce Mon Sep 17 00:00:00 2001 From: Jarrod Brockman Date: Fri, 21 Oct 2016 21:25:26 +0200 Subject: [PATCH 2/4] fix up implicit conversions and make errors more verbose --- scripts/run-tut.sh | 2 +- tutorials/tour/implicit-conversions.md | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/run-tut.sh b/scripts/run-tut.sh index c9fafcc4e5..17a6299e03 100755 --- a/scripts/run-tut.sh +++ b/scripts/run-tut.sh @@ -2,4 +2,4 @@ COURSIER_CLASSPATH="$(./coursier fetch -p com.chuusai:shapeless_2.11:2.3.1 org.scala-lang.modules::scala-xml:1.0.3)" -./coursier launch -r "https://dl.bintray.com/tpolecat/maven/" org.tpolecat:tut-core_2.11:0.4.4 -- . tut-tmp '.*\.md$' -classpath "$COURSIER_CLASSPATH" -Xfatal-warnings +./coursier launch -r "https://dl.bintray.com/tpolecat/maven/" org.tpolecat:tut-core_2.11:0.4.4 -- . tut-tmp '.*\.md$' -classpath "$COURSIER_CLASSPATH" -Xfatal-warnings -feature diff --git a/tutorials/tour/implicit-conversions.md b/tutorials/tour/implicit-conversions.md index aa53946c5c..84232143df 100644 --- a/tutorials/tour/implicit-conversions.md +++ b/tutorials/tour/implicit-conversions.md @@ -17,7 +17,7 @@ Implicit conversions are applied in two situations: * If an expression `e` is of type `S`, and `S` does not conform to the expression's expected type `T`. * In a selection `e.m` with `e` of type `T`, if the selector `m` does not denote a member of `T`. -In the first case, a conversion `c` is searched for which is applicable to `e` and whose result type conforms to `T`. +In the first case, a conversion `c` is searched for which is applicable to `e` and whose result type conforms to `T`. In the second case, a conversion `c` is searched for which is applicable to `e` and whose result contains a member named `m`. The following operation on the two lists xs and ys of type `List[Int]` is legal: @@ -29,11 +29,13 @@ xs <= ys assuming the implicit methods `list2ordered` and `int2ordered` defined below are in scope: ``` +import scala.language.implicitConversions + implicit def list2ordered[A](x: List[A]) (implicit elem2ordered: A => Ordered[A]): Ordered[List[A]] = new Ordered[List[A]] { /* .. */ } -implicit def int2ordered(x: Int): Ordered[Int] = +implicit def int2ordered(x: Int): Ordered[Int] = new Ordered[Int] { /* .. */ } ``` From d27a4754edf8aa700f2d0ea9c263f9eeb2940001 Mon Sep 17 00:00:00 2001 From: Jarrod Brockman Date: Fri, 21 Oct 2016 21:36:33 +0200 Subject: [PATCH 3/4] put import in the correct place in file --- tutorials/tour/implicit-conversions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/tour/implicit-conversions.md b/tutorials/tour/implicit-conversions.md index 84232143df..626ea7769d 100644 --- a/tutorials/tour/implicit-conversions.md +++ b/tutorials/tour/implicit-conversions.md @@ -44,6 +44,8 @@ The implicitly imported object `scala.Predef` declares several predefined types For example, when calling a Java method that expects a `java.lang.Integer`, you are free to pass it a `scala.Int` instead. That's because Predef includes the following implicit conversions: ```tut +import scala.language.implicitConversions + implicit def int2Integer(x: Int) = java.lang.Integer.valueOf(x) ``` From 9d2f987b49867bd83fc0d544d56f5116b8dc35ba Mon Sep 17 00:00:00 2001 From: Jarrod Brockman Date: Fri, 21 Oct 2016 22:03:46 +0200 Subject: [PATCH 4/4] remove extra import --- tutorials/tour/implicit-conversions.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutorials/tour/implicit-conversions.md b/tutorials/tour/implicit-conversions.md index 626ea7769d..71db42e38a 100644 --- a/tutorials/tour/implicit-conversions.md +++ b/tutorials/tour/implicit-conversions.md @@ -29,8 +29,6 @@ xs <= ys assuming the implicit methods `list2ordered` and `int2ordered` defined below are in scope: ``` -import scala.language.implicitConversions - implicit def list2ordered[A](x: List[A]) (implicit elem2ordered: A => Ordered[A]): Ordered[List[A]] = new Ordered[List[A]] { /* .. */ }