Skip to content

Commit 9268573

Browse files
committed
Allow bottom types as hk type arguments
Fixes problem raised in #966.
1 parent b8e05d5 commit 9268573

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

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

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

331-
/** Eta expand the prefix in front of any refinements. */
332-
def EtaExpandCore(implicit ctx: Context): Type = self.stripTypeVar match {
331+
/** Eta expand the prefix in front of any refinements.
332+
* @param tparamsForBottom Type parameters to use if core is a bottom type
333+
*/
334+
def EtaExpandCore(tparamsForBottom: List[TypeSymbol])(implicit ctx: Context): Type = self.stripTypeVar match {
333335
case self: RefinedType =>
334-
self.derivedRefinedType(self.parent.EtaExpandCore, self.refinedName, self.refinedInfo)
336+
self.derivedRefinedType(self.parent.EtaExpandCore(tparamsForBottom), self.refinedName, self.refinedInfo)
337+
case tp: TypeRef if defn.isBottomClass(tp.symbol) =>
338+
self.LambdaAbstract(tparamsForBottom)
335339
case _ =>
336340
self.EtaExpand(self.typeParams)
337341
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ object Types {
15171517
// After substitution we might end up with a type like
15181518
// `C { type hk$0 = T0; ...; type hk$n = Tn } # $Apply`
15191519
// where C is a class. In that case we eta expand `C`.
1520-
derivedSelect(prefix.EtaExpandCore)
1520+
prefix.EtaExpandCore(this.prefix.typeConstructor.typeParams)
15211521
}
15221522
else newLikeThis(prefix)
15231523
}

tests/pos/i966.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Test {
2+
def foo[M[_]]: M[Int] = ???
3+
val x = foo[Nothing]
4+
}

0 commit comments

Comments
 (0)