Commit e2fdcb2
committed
Special case comparisons between LazyRefs and bottom/top types
Fixes #11064
When comparing a LazyRef with some other type, we need to force the LazyRef
which can potentially lead to a cycle (as observed in #11064). However, in the situations
```
Nothing <: LazyRef(...)
LazyRef(...) <: Any
```
we can skip that since the comparison is always true. This scheme fixes #11064, but it breaks
down in similar situations if additional bounds are introduced (see neg/i11064.scala).
So it is quite fragile. But it's probably the best we can do.
The example in #11064 looks harmless, but type-theoretically it's actually a pretty explosive
mix of F-bounded types and existential types (in Scala 2). In Scala 2, we need to force more
for F-bounded types and we need to approximate existential types by dependent types, so
not everything works the same way.
My long term advice would be: get rid of F-bounds. Model them with intersections at the
use site.1 parent 5672999 commit e2fdcb2
File tree
3 files changed
+22
-3
lines changed- compiler/src/dotty/tools/dotc/core
- tests
- neg
- pos
3 files changed
+22
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
| 376 | + | |
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
| 424 | + | |
424 | 425 | | |
425 | 426 | | |
426 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments