Skip to content

Commit a78a41b

Browse files
committed
Simplify EtaExpand
1 parent cc41d38 commit a78a41b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Decorators._
1010
import util.Stats._
1111
import Names._
1212
import NameOps._
13-
import Variances.{varianceConforms, variancesConform}
13+
import Variances.variancesConform
1414
import dotty.tools.dotc.config.Config
1515

1616
object TypeApplications {
@@ -250,11 +250,9 @@ class TypeApplications(val self: Type) extends AnyVal {
250250
/** Convert a type constructor `TC` which has type parameters `X1, ..., Xn`
251251
* to `[X1, ..., Xn] -> TC[X1, ..., Xn]`.
252252
*/
253-
def EtaExpand(tparams: List[TypeSymbol])(implicit ctx: Context): Type = {
254-
val tparamsToUse = if (variancesConform(typeParams, tparams)) tparams else typeParamSymbols
255-
HKTypeLambda.fromParams(tparamsToUse, self.appliedTo(tparams.map(_.typeRef)))
253+
def EtaExpand(tparams: List[TypeSymbol])(implicit ctx: Context): Type =
254+
HKTypeLambda.fromParams(tparams, self.appliedTo(tparams.map(_.typeRef)))
256255
//.ensuring(res => res.EtaReduce =:= self, s"res = $res, core = ${res.EtaReduce}, self = $self, hc = ${res.hashCode}")
257-
}
258256

259257
/** If self is not lambda-bound, eta expand it. */
260258
def ensureLambdaSub(implicit ctx: Context): Type =

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ object VarianceChecker {
4949
def apply(x: Boolean, t: Type) = x && {
5050
t match {
5151
case tref: TypeParamRef if tref.binder `eq` tl =>
52-
val v = paramVarianceSign(tref)
53-
varianceConforms(variance, v) || { error(tref); false }
52+
varianceConforms(variance, paramVarianceSign(tref))
53+
|| { error(tref); false }
5454
case AnnotatedType(_, annot) if annot.symbol == defn.UncheckedVarianceAnnot =>
5555
x
5656
case _ =>

0 commit comments

Comments
 (0)