Skip to content

Commit e5e489e

Browse files
authored
Merge pull request #9085 from lampepfl/revert-9084-fix-#9061
Revert "Fix #9061: Treat `type F <: [X] => G` like `type F[X] <: G`."
2 parents cbd52f1 + 34cded1 commit e5e489e

File tree

4 files changed

+6
-37
lines changed

4 files changed

+6
-37
lines changed

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

-2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,4 @@ object Variances {
156156
if (v > 0) "+"
157157
else if (v < 0) "-"
158158
else ""
159-
160-
val alwaysInvariant: Any => Invariant.type = Function.const(Invariant)
161159
}

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

+2-20
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import util.Spans._
1515
import util.Property
1616
import collection.mutable
1717
import tpd.ListOfTreeDecorator
18-
import Variances.alwaysInvariant
1918
import config.{Config, Feature}
2019
import config.Printers.typr
2120
import Annotations._
@@ -969,10 +968,7 @@ class Namer { typer: Typer =>
969968
override final def typeSig(sym: Symbol): Type =
970969
val tparamSyms = completerTypeParams(sym)(ictx)
971970
given ctx as Context = nestedCtx
972-
973-
def abstracted(tp: TypeBounds): TypeBounds =
974-
HKTypeLambda.boundsFromParams(tparamSyms, tp)
975-
971+
def abstracted(tp: TypeBounds): TypeBounds = HKTypeLambda.boundsFromParams(tparamSyms, tp)
976972
val dummyInfo1 = abstracted(TypeBounds.empty)
977973
sym.info = dummyInfo1
978974
sym.setFlag(Provisional)
@@ -1002,22 +998,8 @@ class Namer { typer: Typer =>
1002998
}
1003999
sym.info = dummyInfo2
10041000

1005-
// Treat the parameters of an upper type lambda bound on the RHS as non-variant.
1006-
// E.g. type F <: [X] =>> G and type F[X] <: G
1007-
// are treated alike.
1008-
def addVariances(tp: Type): Type = tp match
1009-
case tp: TypeBounds =>
1010-
def recur(tp: Type): Type = tp match
1011-
case tp: HKTypeLambda if !tp.isDeclaredVarianceLambda =>
1012-
tp.withVariances(tp.paramNames.map(alwaysInvariant))
1013-
.derivedLambdaType(resType = recur(tp.resType))
1014-
case tp => tp
1015-
tp.derivedTypeBounds(tp.lo, recur(tp.hi))
1016-
case _ =>
1017-
tp
1018-
10191001
val rhs1 = typedAheadType(rhs)
1020-
val rhsBodyType: TypeBounds = addVariances(rhs1.tpe).toBounds
1002+
val rhsBodyType: TypeBounds = rhs1.tpe.toBounds
10211003
val unsafeInfo = if (isDerived) rhsBodyType else abstracted(rhsBodyType)
10221004

10231005
def opaqueToBounds(info: Type): Type =

compiler/src/dotty/tools/dotc/util/common.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import core.Types.WildcardType
66
/** Common values hoisted out for performance */
77
object common {
88

9-
val alwaysTrue: Any => Boolean = Function.const(true)
10-
val alwaysFalse: Any => Boolean = Function.const(false)
11-
val alwaysZero: Any => Int = Function.const(0)
12-
val alwaysWildcardType: Any => WildcardType.type = Function.const(WildcardType)
9+
val alwaysTrue: Any => Boolean = Function.const(true) _
10+
val alwaysFalse: Any => Boolean = Function.const(false) _
11+
val alwaysZero: Any => Int = Function.const(0) _
12+
val alwaysWildcardType: Any => WildcardType.type = Function.const(WildcardType) _
1313
}

tests/neg/i9061.scala

-11
This file was deleted.

0 commit comments

Comments
 (0)