Skip to content

Commit 186331b

Browse files
committed
Don't check bounds of higher-kinded applications at CC
This is very dubious, but we need it for now to make Tuple go through.
1 parent fa03916 commit 186331b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ object Checking {
150150
// Exempted are types that are not themselves capture-checked.
151151
// Since the type constructor could not foresee possible capture sets,
152152
// it's better to be lenient for backwards compatibility.
153-
// Also exempted are match aliases. See tuple-ops.scala for an example that
154-
// would fail otherwise.
153+
// Also exempted are match aliases and higher-kinded applications.
154+
// See tuple-ops.scala and tuple-ops-2.scala for examples that would fail otherwise.
155155
def checkableUnderCC =
156-
tycon.typeSymbol.is(CaptureChecked) && !tp.isMatchAlias
156+
tycon.typeSymbol.is(CaptureChecked) && !tp.isMatchAlias && !tycon.isLambdaSub
157157
if !(tycon.typeSymbol.is(JavaDefined) && ctx.compilationUnit.isJava)
158158
// Don't check bounds in Java units that refer to Java type constructors.
159159
// Scala is not obliged to do Java type checking and in fact i17763 goes wrong
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sealed trait Tup
2+
case object Emp extends Tup
3+
type Emp = Emp.type
4+
case class Cons[h, t <: Tup](hh: h, tt: t) extends Tup
5+
6+
type Union[T <: Tup] = T match
7+
case Emp => Nothing
8+
case Cons[h, t] => h | Union[t]
9+
10+
type Concat[T <: Tup, U <: Tup] <: Tup = T match
11+
case Emp => U
12+
case Cons[h, t] => Cons[h, Concat[t, U]]
13+
14+
type FlatMap[T <: Tup, F[_ <: Union[T]] <: Tup] <: Tup = T match
15+
case Emp => Emp
16+
case Cons[h, t] => Concat[F[h], FlatMap[t, F]]
17+
18+
type A =
19+
FlatMap[Cons[Boolean, Cons[String, Emp]], [T] =>> Cons[T, Cons[List[T], Emp]]]

0 commit comments

Comments
 (0)