Skip to content

Commit 6067ab7

Browse files
authored
Merge pull request #6156 from milessabin/topic/i6014
Preserve tvar bounds that represent kinds
2 parents b6e4acf + 2e1428d commit 6067ab7

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,10 @@ object Contexts {
929929
// - we don't want TyperState instantiating these TypeVars
930930
// - we don't want TypeComparer constraining these TypeVars
931931
val poly = PolyType(DepParamName.fresh(sym.name.toTypeName) :: Nil)(
932-
pt => TypeBounds.empty :: Nil,
932+
pt => (sym.info match {
933+
case tb @ TypeBounds(_, hi) if hi.isLambdaSub => tb
934+
case _ => TypeBounds.empty
935+
}) :: Nil,
933936
pt => defn.AnyType)
934937
new TypeVar(poly.paramRefs.head, creatorState = null)
935938
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
559559
if (tparams1.nonEmpty)
560560
return recur(
561561
HKTypeLambda.fromParams(tparams1, tp1.appliedTo(tparams1.map(_.paramRef))),
562-
tp2)
562+
tp2) || fourthTry
563563
else tp2 match {
564564
case EtaExpansion(tycon2) if tycon2.symbol.isClass =>
565565
return recur(tp1, tycon2)

compiler/test/dotc/pos-from-tasty.blacklist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ i4006c.scala
2323

2424
# Not sure what's wring here
2525
i4203.scala
26-
t6278-synth-def.scala
26+
t6278-synth-def.scala

tests/pos/i6014-gadt.scala

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import scala.compiletime._
2+
3+
object Test1 {
4+
type Foo[F[_]]
5+
type Bar[T] = T match {
6+
case Foo[f] => f[Int]
7+
}
8+
9+
val li: Bar[Foo[List]] = List(1, 2, 3)
10+
}
11+
12+
object Test2 {
13+
inline def summon[T] = implicit match {
14+
case t: T => t
15+
}
16+
17+
class Foo[F[_]]
18+
19+
inline def bar[T] = inline erasedValue[T] match {
20+
case _: Foo[f] => summon[f[Int]]
21+
}
22+
23+
implicit val li: List[Int] = List(1, 2, 3)
24+
val lii = bar[Foo[List]]
25+
}
26+
27+
object Test3 {
28+
inline def summon[T] = implicit match {
29+
case t: T => t
30+
}
31+
32+
type K1Top = [t] => Any
33+
34+
class Foo[F <: K1Top]
35+
36+
inline def bar[T] = inline erasedValue[T] match {
37+
case _: Foo[f] => summon[f[Int]]
38+
}
39+
40+
implicit val li: List[Int] = List(1, 2, 3)
41+
val lii = bar[Foo[List]]
42+
}
43+
44+
object Test4 {
45+
inline def summon[T] = implicit match {
46+
case t: T => t
47+
}
48+
49+
class Foo[F[t] >: List[t]]
50+
51+
inline def bar[T] = inline erasedValue[T] match {
52+
case _: Foo[f] => summon[f[Int]]
53+
}
54+
55+
implicit val li: List[Int] = List(1, 2, 3)
56+
val lii = bar[Foo[List]]
57+
}

0 commit comments

Comments
 (0)