Skip to content

Commit

Permalink
Fix join of values
Browse files Browse the repository at this point in the history
After #12711, it is no longer the case that `Warm < ThisRef`.
The reason is that the class parameters for `ThisRef` are always hot,
while it is not the case anymore after #12711.

Actually even before #12711, it's not the case because the outers of
warm objects may not be hot. The theory does not have inner classes,
it thus does not suffer from the problem.
  • Loading branch information
liufengyun authored and EnzeXing committed Jul 30, 2021
1 parent a59e6a3 commit e901a36
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions compiler/src/dotty/tools/dotc/transform/init/Semantic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,20 @@ class Semantic {
* Value = Hot | Cold | Warm | ThisRef | Fun | RefSet
*
* Cold
* ┌──────► ▲ ──┐ ◄────┐
* │ │ │ │
* │ │ │ │
* ThisRef(C) │ │
* │ │ │
* Warm(D) Fun RefSet
* │ ▲ ▲ ▲
* │ │ │ │
* Warm(C) │ │
* ▲ │ │ │
* │ │ │ │
* └─────────┴──────┴───────┘
* ┌──────► ▲ ◄────┐ ◄────┐
* │ │ │ │
* │ │ │ │
* | │ │ │
* | │ │
* ThisRef(C) Warm(D) Fun RefSet
* │ ▲ ▲ ▲
* │ │ │ │
* | │ │
* ▲ │ │ │
* │ │ │ │
* └─────────┴──────┴───────┘
* Hot
*
* The most important ordering is the following:
*
* Hot ⊑ Warm(C) ⊑ ThisRef(C) ⊑ Cold
*
* The diagram above does not reflect relationship between `RefSet`
* and other values. `RefSet` represents a set of values which could
* be `ThisRef`, `Warm` or `Fun`. The following ordering applies for
Expand Down Expand Up @@ -302,9 +298,6 @@ class Semantic {
case (Cold, _) => Cold
case (_, Cold) => Cold

case (a: Warm, b: ThisRef) if a.klass == b.klass => b
case (a: ThisRef, b: Warm) if a.klass == b.klass => a

case (a: (Fun | Warm | ThisRef), b: (Fun | Warm | ThisRef)) => RefSet(a :: b :: Nil)

case (a: (Fun | Warm | ThisRef), RefSet(refs)) => RefSet(a :: refs)
Expand Down

0 comments on commit e901a36

Please sign in to comment.