Commit a095a4b
committed
Don't interpolate downwards to a bottom type
If the result of a covariant type variable interpolation would be a bottom type,
wait instead. This could make the variable be inferred to its upper bound after all,
if we do not need a fully instantiated type right away.
This makes a difference for indentation whereever we have a situation like this:
```
def foo: T =
bla.asInstanceOf
```
With indentation on, this is now equivalent to
```
def foo: T = {
bla.asInstanceof
}
```
This means there is now an added opportunity for an interpolation step, of
the asInstanceOf, which would go downwards to Nothing. So indentation changes
the inferred type, which is very bad. With the commit the problem is
avoided.
Two tests are reclassified:
i536.scala previously compiled since the type argument was inferred to be Nothing.
But that inference is useless; it just hides a runtime failure. The issue #536
only complained that the compiler crashed, so having a negative outcome
is permissible.
enum-interop is similar except that the example makes even less sense and compiles only
because Nothing was inferred by accedient.1 parent 07be6d4 commit a095a4b
File tree
4 files changed
+16
-2
lines changed- compiler/src/dotty/tools/dotc/typer
- tests
- neg
- pending/pos
- run
4 files changed
+16
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
438 | 445 | | |
439 | 446 | | |
440 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments