diff --git a/compiler/src/dotty/tools/dotc/core/Contexts.scala b/compiler/src/dotty/tools/dotc/core/Contexts.scala index b3a9fe523872..9ac722cf0164 100644 --- a/compiler/src/dotty/tools/dotc/core/Contexts.scala +++ b/compiler/src/dotty/tools/dotc/core/Contexts.scala @@ -929,7 +929,10 @@ object Contexts { // - we don't want TyperState instantiating these TypeVars // - we don't want TypeComparer constraining these TypeVars val poly = PolyType(DepParamName.fresh(sym.name.toTypeName) :: Nil)( - pt => TypeBounds.empty :: Nil, + pt => (sym.info match { + case tb @ TypeBounds(_, hi) if hi.isLambdaSub => tb + case _ => TypeBounds.empty + }) :: Nil, pt => defn.AnyType) new TypeVar(poly.paramRefs.head, creatorState = null) } diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 3314cb2abfef..7899042296db 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -559,7 +559,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] { if (tparams1.nonEmpty) return recur( HKTypeLambda.fromParams(tparams1, tp1.appliedTo(tparams1.map(_.paramRef))), - tp2) + tp2) || fourthTry else tp2 match { case EtaExpansion(tycon2) if tycon2.symbol.isClass => return recur(tp1, tycon2) diff --git a/compiler/test/dotc/pos-from-tasty.blacklist b/compiler/test/dotc/pos-from-tasty.blacklist index b5198d0d877a..f7ab55c59b01 100644 --- a/compiler/test/dotc/pos-from-tasty.blacklist +++ b/compiler/test/dotc/pos-from-tasty.blacklist @@ -23,4 +23,4 @@ i4006c.scala # Not sure what's wring here i4203.scala -t6278-synth-def.scala +t6278-synth-def.scala \ No newline at end of file diff --git a/tests/pos/i6014-gadt.scala b/tests/pos/i6014-gadt.scala new file mode 100644 index 000000000000..721c638051f0 --- /dev/null +++ b/tests/pos/i6014-gadt.scala @@ -0,0 +1,57 @@ +import scala.compiletime._ + +object Test1 { + type Foo[F[_]] + type Bar[T] = T match { + case Foo[f] => f[Int] + } + + val li: Bar[Foo[List]] = List(1, 2, 3) +} + +object Test2 { + inline def summon[T] = implicit match { + case t: T => t + } + + class Foo[F[_]] + + inline def bar[T] = inline erasedValue[T] match { + case _: Foo[f] => summon[f[Int]] + } + + implicit val li: List[Int] = List(1, 2, 3) + val lii = bar[Foo[List]] +} + +object Test3 { + inline def summon[T] = implicit match { + case t: T => t + } + + type K1Top = [t] => Any + + class Foo[F <: K1Top] + + inline def bar[T] = inline erasedValue[T] match { + case _: Foo[f] => summon[f[Int]] + } + + implicit val li: List[Int] = List(1, 2, 3) + val lii = bar[Foo[List]] +} + +object Test4 { + inline def summon[T] = implicit match { + case t: T => t + } + + class Foo[F[t] >: List[t]] + + inline def bar[T] = inline erasedValue[T] match { + case _: Foo[f] => summon[f[Int]] + } + + implicit val li: List[Int] = List(1, 2, 3) + val lii = bar[Foo[List]] +}