Skip to content

Commit 7649eaf

Browse files
committed
Cleanups
1 parent 46e3d77 commit 7649eaf

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

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

+3-23
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ object TypeOps:
5757

5858
/** The TypeMap handling the asSeenFrom */
5959
class AsSeenFromMap(pre: Type, cls: Symbol)(using Context) extends ApproximatingTypeMap, IdempotentCaptRefMap {
60-
/** Set to true when the result of `apply` was approximated to avoid an unstable prefix. */
61-
private var approximated: Boolean = false
6260

6361
/** The number of range approximations in invariant or contravariant positions
62+
* performed by this TypeMap.
6463
* - Incremented each time we produce a range.
6564
* - Decremented each time we drop a prefix range by forwarding to a type alias
6665
* or singleton type.
@@ -83,22 +82,8 @@ object TypeOps:
8382
case _ =>
8483
if (thiscls.derivesFrom(cls) && pre.baseType(thiscls).exists)
8584
if (variance <= 0 && !isLegalPrefix(pre))
86-
if true then
87-
approxCount += 1
88-
range(defn.NothingType, pre)
89-
else
90-
if (variance < 0) {
91-
approximated = true
92-
defn.NothingType
93-
}
94-
else
95-
// Don't set the `approximated` flag yet: if this is a prefix
96-
// of a path, we might be able to dealias the path instead
97-
// (this is handled in `ApproximatingTypeMap`). If dealiasing
98-
// is not possible, then `expandBounds` will end up being
99-
// called which we override to set the `approximated` flag.
100-
range(defn.NothingType, pre)
101-
85+
approxCount += 1
86+
range(defn.NothingType, pre)
10287
else pre
10388
else if (pre.termSymbol.is(Package) && !thiscls.is(Package))
10489
toPrefix(pre.select(nme.PACKAGE), cls, thiscls)
@@ -131,11 +116,6 @@ object TypeOps:
131116
// derived infos have already been subjected to asSeenFrom, hence to need to apply the map again.
132117
tp
133118

134-
//override protected def expandBounds(tp: TypeBounds): Type = {
135-
// approximated = true
136-
// super.expandBounds(tp)
137-
//}
138-
139119
override protected def useAlternate(tp: Type): Type =
140120
assert(approxCount > 0)
141121
approxCount -= 1

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -5819,15 +5819,11 @@ object Types {
58195819
tp.argForParam(pre) match {
58205820
case arg @ TypeRef(pre, _) if pre.isArgPrefixOf(arg.symbol) =>
58215821
arg.info match {
5822-
case argInfo: TypeBounds =>
5823-
expandBounds(argInfo)
5824-
case argInfo =>
5825-
useAlternate(arg)
5822+
case argInfo: TypeBounds => expandBounds(argInfo)
5823+
case argInfo => useAlternate(arg)
58265824
}
5827-
case arg: TypeBounds =>
5828-
expandBounds(arg)
5829-
case arg =>
5830-
useAlternate(arg)
5825+
case arg: TypeBounds => expandBounds(arg)
5826+
case arg => useAlternate(arg)
58315827
}
58325828

58335829
/** Derived selection.

0 commit comments

Comments
 (0)