Skip to content

Commit 717b61c

Browse files
committed
More section on changes
1 parent aa4217f commit 717b61c

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
layout: doc-page
3+
title: "Changes in Implicit Resolution"
4+
---
5+
6+
Implicit resolution uses a new algorithm which caches implicit results
7+
more aggressively for perforance. There are also some changes that
8+
affect implicits on the language level.
9+
10+
1. Types of implicit values and result types of implicit methods
11+
must be explicitly declared. Excepted are only values in local blocks
12+
where the type may still be inferred:
13+
14+
class C {
15+
16+
val ctx: Context = ... // ok
17+
18+
/*!*/ implicit val x = ... // error: type must be given explicitly
19+
20+
/*!*/ next(): Context = ... // error: type must be given explicitly
21+
22+
val y = {
23+
implicit val ctx = this.ctx // ok
24+
...
25+
}
26+
27+
2. Implicit parameters may not have singleton types.
28+
29+
/*!*/ def f(implicit x: y.type) // error `y.type` not allowed as type of implicit
30+
31+
3. Nesting is now taken into account for selecting an implicit.
32+
Consider for instance the following scenario
33+
34+
def f(implicit i: C) = {
35+
def g(implicit j: C) = {
36+
implicitly[C]
37+
}
38+
}
39+
40+
This will now resolve the `implicitly` call to `j`, because `j` is nested
41+
more deeply than `i`. Previously, this would have resulted in an
42+
ambiguity error.
43+
44+
[//] # todo: expand with precise rules
45+
46+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
layout: doc-page
3+
title: "Changes in Type Checking"
4+
---
5+
6+
[//] # todo: fill in
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
layout: doc-page
3+
title: "Changes in Type Inference"
4+
---
5+
6+
[//] # todo: fill in
7+

docs/sidebar.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sidebar:
2727
url: docs/reference/multiversal-equality.html
2828
- title: Inline
2929
url: docs/reference/inline.html
30-
- title: Smaller Changes
30+
- title: Smaller Additions
3131
subsection:
3232
- title: By-Name Implicits
3333
url: docs/reference/implicit-by-name-parameters.html
@@ -41,6 +41,12 @@ sidebar:
4141
url: docs/reference/changed/lazy-vals.md
4242
- title: Structural Types
4343
url: docs/reference/changed/structural-types.md
44+
- title: Type Checking
45+
url: docs/reference/changed/type-checking.md
46+
- title: Type Inference
47+
url: docs/reference/changed/type-inference.md
48+
- title: Implicit Resolution
49+
url: docs/reference/changed/implicit-resolution.md
4450
- title: Dropped Features
4551
subsection:
4652
- title: DelayedInit

0 commit comments

Comments
 (0)