Skip to content

Commit bde77d4

Browse files
committed
Don't do eta expansion on bottom types
1 parent ded374a commit bde77d4

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,10 @@ class TypeApplications(val self: Type) extends AnyVal {
373373
//.ensuring(res => res.EtaReduce =:= self, s"res = $res, core = ${res.EtaReduce}, self = $self, hc = ${res.hashCode}")
374374
}
375375

376-
/** Eta expand the prefix in front of any refinements.
377-
* @param tparamsForBottom Type parameters to use if core is a bottom type
378-
*/
379-
def EtaExpandCore(tparamsForBottom: List[TypeSymbol])(implicit ctx: Context): Type = self.stripTypeVar match {
376+
/** Eta expand the prefix in front of any refinements. */
377+
def EtaExpandCore(implicit ctx: Context): Type = self.stripTypeVar match {
380378
case self: RefinedType =>
381-
self.derivedRefinedType(self.parent.EtaExpandCore(tparamsForBottom), self.refinedName, self.refinedInfo)
382-
case tp: TypeRef if defn.isBottomClass(tp.symbol) =>
383-
self.LambdaAbstract(tparamsForBottom)
379+
self.derivedRefinedType(self.parent.EtaExpandCore, self.refinedName, self.refinedInfo)
384380
case _ =>
385381
self.EtaExpand(self.typeParams)
386382
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,8 +1538,10 @@ object Types {
15381538
*
15391539
* T#A --> B if A is bound to an alias `= B` in T
15401540
*
1541-
* (S & T)#A --> S#A if T does not have a member namd A
1542-
* --> T#A if S does not have a member namd A
1541+
* If Config.splitProjections is set:
1542+
*
1543+
* (S & T)#A --> S#A if T does not have a member named A
1544+
* --> T#A if S does not have a member named A
15431545
* --> S#A & T#A otherwise
15441546
* (S | T)#A --> S#A | T#A
15451547
*/
@@ -1548,11 +1550,13 @@ object Types {
15481550
else if (isType) {
15491551
val res = prefix.lookupRefined(name)
15501552
if (res.exists) res
1551-
else if (name == tpnme.hkApply && prefix.classNotLambda)
1553+
else if (name == tpnme.hkApply && prefix.classNotLambda) {
15521554
// After substitution we might end up with a type like
15531555
// `C { type hk$0 = T0; ...; type hk$n = Tn } # $Apply`
15541556
// where C is a class. In that case we eta expand `C`.
1555-
derivedSelect(prefix.EtaExpandCore(this.prefix.typeConstructor.typeParams))
1557+
if (defn.isBottomType(prefix)) prefix.classSymbol.typeRef
1558+
else derivedSelect(prefix.EtaExpandCore)
1559+
}
15561560
else if (Config.splitProjections)
15571561
prefix match {
15581562
case prefix: AndType =>

0 commit comments

Comments
 (0)