Skip to content

Commit 757cf3f

Browse files
committed
Refine checkKindRank
Previous way of taking the result type was too naive.
1 parent 1d313e9 commit 757cf3f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,14 @@ object Checking {
110110
* A test case is neg/i2771.scala.
111111
*/
112112
def checkKindRank(arg: Tree, paramBounds: TypeBounds)(implicit ctx: Context): Tree = {
113+
def result(tp: Type): Type = tp match {
114+
case tp: HKTypeLambda => tp.resultType
115+
case tp: TypeProxy => result(tp.superType)
116+
case _ => defn.AnyType
117+
}
113118
def kindOK(argType: Type, boundType: Type): Boolean =
114119
!argType.isHK ||
115-
boundType.isHK && kindOK(argType.resultType, boundType.resultType)
120+
boundType.isHK && kindOK(result(argType), result(boundType))
116121
if (kindOK(arg.tpe, paramBounds.hi)) arg
117122
else errorTree(arg, em"${arg.tpe} takes type parameters")
118123
}

0 commit comments

Comments
 (0)