Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d6a15c1

Browse files
committedNov 21, 2015
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 d6a15c1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

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

Lines changed: 3 additions & 3 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,7 +179,7 @@ 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
182+
if (sym.isClass) !sym.isLambdaTrait && !sym.eq(defn.NothingClass)
183183
else sym.isCompleted && self.info.isAlias && self.info.bounds.hi.noHK
184184
}
185185
case _ =>

‎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)
Please sign in to comment.