summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2017-03-09 02:25:55 -0800
committerSom Snytt <som.snytt@gmail.com>2017-03-10 02:58:17 -0800
commitdea2171a1c0f948a3b81cbd2195d99b2fb1b2e5d (patch)
tree0d63ba884aec32fd7ce58496efb839a63d9ddfde /spec
parentc309f9867a557d4edccaebfa399eabcef11bf1bf (diff)
downloadscala-dea2171a1c0f948a3b81cbd2195d99b2fb1b2e5d.tar.gz
scala-dea2171a1c0f948a3b81cbd2195d99b2fb1b2e5d.tar.bz2
scala-dea2171a1c0f948a3b81cbd2195d99b2fb1b2e5d.zip
SI-5621 Missing implicits are supplied by defaults
Make a note in the examples for default args.
Diffstat (limited to 'spec')
-rw-r--r--spec/04-basic-declarations-and-definitions.md9
-rw-r--r--spec/06-expressions.md4
2 files changed, 11 insertions, 2 deletions
diff --git a/spec/04-basic-declarations-and-definitions.md b/spec/04-basic-declarations-and-definitions.md
index 53b34dedc5..c4d3425fff 100644
--- a/spec/04-basic-declarations-and-definitions.md
+++ b/spec/04-basic-declarations-and-definitions.md
@@ -669,6 +669,15 @@ def f(a: Int = 0)(b: Int = a + 1) = b // OK
f(10)() // returns 11 (not 1)
```
+If an [implicit argument](07-implicits.html#implicit-parameters)
+is not found by implicit search, it may be supplied using a default argument.
+
+```scala
+implicit val i: Int = 2
+def f(implicit x: Int, s: String = "hi") = s * x
+f // "hihi"
+```
+
### By-Name Parameters
```ebnf
diff --git a/spec/06-expressions.md b/spec/06-expressions.md
index 48cff1725a..581170c5f9 100644
--- a/spec/06-expressions.md
+++ b/spec/06-expressions.md
@@ -320,7 +320,7 @@ would not typecheck.
### Named and Default Arguments
-If an application might uses named arguments $p = e$ or default
+If an application is to use named arguments $p = e$ or default
arguments, the following conditions must hold.
- For every named argument $p_i = e_i$ which appears left of a positional argument
@@ -330,7 +330,7 @@ arguments, the following conditions must hold.
argument defines a parameter which is already specified by a
positional argument.
- Every formal parameter $p_j:T_j$ which is not specified by either a positional
- or a named argument has a default argument.
+ or named argument has a default argument.
If the application uses named or default
arguments the following transformation is applied to convert it into