Commit 62b7281
committed
Special handling of experimental.captureChecking import
The question is, how do we introduce capture checking safely. There are
two conflicting requirements:
- Capture checking should not leak into standard Scala. It should be
meaningful only in code that has capture checking explicitly enabled.
- We need to be able to build up libraries that express capture information
and that can be consumed from other code. This needs to start with
the standard library itself.
So far, everything related to capture checking was marked experimental. This means
all code that refers to a capture checking abstraction in any way whatsoever needs
to be declared experimental. That clearly does not work for the new use cases.
But fortunately, capture checking has some properties that enable a different scheme.
Specifically, a file compiled under capture checking looks like a completely normal
component (both Tasty and binary) to any other file that uses it and that is not compiled
with captureChecking. Only when the consumer is also compiled with capture checking,
the capturing types of the original file will be revealed. The same holds for binaries.
Capture checking has no effect at all on the binaries that get generated and all types
and annotations needed for capture checking are erased.
This allows the following more flexible scheme:
- We can turn capture checking on with a setting or language import in any source file.
The sources do not have to be @experimental.
- If capture checking is turned on, a number of annotations and other symbols that
are normally experimental are also made available.
The important property is that capture checking in one component cannot poison other normal components. Like
@experimental itself, the whole scheme is transitive.
With the new scheme we do not need a special exemption for the dotty package anymore, so that part
is dropped.1 parent 264cf2e commit 62b7281
File tree
5 files changed
+27
-3
lines changed- compiler/src/dotty/tools/dotc
- config
- core
- typer
- tests/pos-custom-args/no-experimental
5 files changed
+27
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
139 | 142 | | |
140 | | - | |
| 143 | + | |
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1946 | 1946 | | |
1947 | 1947 | | |
1948 | 1948 | | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
1949 | 1957 | | |
1950 | 1958 | | |
1951 | 1959 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
787 | | - | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
788 | 790 | | |
789 | 791 | | |
790 | 792 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments