Skip to content

Commit ca3aa83

Browse files
committed
Drop duplicate extension methods in CheckCaptures
1 parent d335a1a commit ca3aa83

File tree

2 files changed

+1
-101
lines changed

2 files changed

+1
-101
lines changed

compiler/src/dotty/tools/dotc/core/CaptureTypeOps.scala

Lines changed: 0 additions & 65 deletions
This file was deleted.

compiler/src/dotty/tools/dotc/typer/CheckCaptures.scala

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import reporting._
2828
import ProtoTypes._
2929
import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
3030
import CaptureSet.CompareResult
31-
import cc.CaptureOps.toCaptureSet
31+
import cc.CaptureOps.*
3232

3333
object CheckCaptures:
3434
case class Env(owner: Symbol, captured: CaptureSet, isBoxed: Boolean, outer: Env):
@@ -37,41 +37,6 @@ object CheckCaptures:
3737
/** Attachment key for printing trees with rechecked types */
3838
val RecheckedType = Property.Key[Type]
3939

40-
extension (tp: Type)
41-
42-
/** If this is type variable instantiated or upper bounded with a capturing type,
43-
* the capture set associated with that type. Extended to and-or types and
44-
* type proxies in the obvious way. If a term has a type with a boxed captureset,
45-
* that captureset counts towards the capture variables of the envirionment.
46-
*/
47-
def boxedCaptured(using Context): CaptureSet =
48-
def getBoxed(tp: Type, enabled: Boolean): CaptureSet = tp match
49-
case tp: CapturingType if enabled => tp.refs
50-
case tp: TypeVar => getBoxed(tp.underlying, enabled = true)
51-
case tp: TypeRef if tp.symbol == defn.AnyClass && enabled => CaptureSet.universal
52-
case tp: TypeProxy => getBoxed(tp.superType, enabled)
53-
case tp: AndType => getBoxed(tp.tp1, enabled) ++ getBoxed(tp.tp2, enabled)
54-
case tp: OrType => getBoxed(tp.tp1, enabled) ** getBoxed(tp.tp2, enabled)
55-
case _ => CaptureSet.empty
56-
getBoxed(tp, enabled = false)
57-
58-
/** If this type appears as an expected type of a term, does it imply
59-
* that the term should be boxed? ^^^ Special treat Any?
60-
*/
61-
def needsBox(using Context): Boolean = tp match
62-
case _: TypeVar => true
63-
case tp: TypeRef =>
64-
tp.info match
65-
case TypeBounds(lo, _) => lo.needsBox
66-
case _ => false
67-
case tp: RefinedOrRecType => tp.parent.needsBox
68-
case tp: AnnotatedType => tp.parent.needsBox
69-
case tp: LazyRef => tp.ref.needsBox
70-
case tp: AndType => tp.tp1.needsBox || tp.tp2.needsBox
71-
case tp: OrType => tp.tp1.needsBox && tp.tp2.needsBox
72-
case _ => false
73-
end extension
74-
7540
class CheckCaptures extends Recheck:
7641
thisPhase =>
7742

0 commit comments

Comments
 (0)