Skip to content

Commit 8624c61

Browse files
committed
Refine same-kind criterion
- Need to take of AnyKind - need to also copmare results
1 parent bcb20c4 commit 8624c61

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,17 +524,21 @@ trait ConstraintHandling[AbstractContext] {
524524
pruneLambdaParams(bound)
525525
}
526526

527-
def sameKind(tp1: Type, tp2: Type): Boolean =
528-
tp1.typeParams.corresponds(tp2.typeParams)((p1, p2) =>
529-
sameKind(p1.paramInfo, p2.paramInfo))
527+
def kindCompatible(tp1: Type, tp2: Type): Boolean =
528+
val tparams1 = tp1.typeParams
529+
val tparams2 = tp2.typeParams
530+
tparams1.corresponds(tparams2)((p1, p2) => kindCompatible(p1.paramInfo, p2.paramInfo))
531+
&& (tparams1.isEmpty || kindCompatible(tp1.hkResult, tp2.hkResult))
532+
|| tp1.hasAnyKind
533+
|| tp2.hasAnyKind
530534

531535
try bound match {
532536
case bound: TypeParamRef if constraint contains bound =>
533537
addParamBound(bound)
534538
case _ =>
535539
val pbound = prune(bound)
536540
pbound.exists
537-
&& sameKind(param, pbound)
541+
&& kindCompatible(param, pbound)
538542
&& (if fromBelow then addLowerBound(param, pbound) else addUpperBound(param, pbound))
539543
}
540544
finally addConstraintInvocations -= 1

0 commit comments

Comments
 (0)