Skip to content

Commit 0da20e7

Browse files
committed
TypeApplications#noHK: return false for Nothing
Otherwise, when a higher-kinded type variable is instantiated to Nothing, we will try to eta-expand it and trigger an assertion in Definitions#LambdaTrait.
1 parent ea1ee47 commit 0da20e7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ class TypeApplications(val self: Type) extends AnyVal {
166166
}
167167

168168
/** True if it can be determined without forcing that the class symbol
169-
* of this application exists and is not a lambda trait.
169+
* of this application exists and is not a lambda trait or Nothing.
170170
* Equivalent to
171171
*
172-
* self.classSymbol.exists && !self.classSymbol.isLambdaTrait
172+
* self.classSymbol.exists && !self.classSymbol.isLambdaTrait && !self.isRef(defn.NothingClass)
173173
*
174174
* but without forcing anything.
175175
*/
@@ -179,8 +179,9 @@ class TypeApplications(val self: Type) extends AnyVal {
179179
case self: TypeRef =>
180180
(self.denot.exists) && {
181181
val sym = self.symbol
182-
if (sym.isClass) !sym.isLambdaTrait
183-
else sym.isCompleted && self.info.isAlias && self.info.bounds.hi.noHK
182+
if (sym.isClass) !sym.isLambdaTrait && !sym.eq(defn.NothingClass)
183+
else sym.isCompleted && !self.isRef(defn.NothingClass) && self.info.isAlias &&
184+
self.info.bounds.hi.noHK
184185
}
185186
case _ =>
186187
false

tests/pos/hk_nothing.scala

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

0 commit comments

Comments
 (0)