diff --git a/compiler/src/dotty/tools/dotc/core/GadtConstraint.scala b/compiler/src/dotty/tools/dotc/core/GadtConstraint.scala index 1cbfabc08958..5a8938602523 100644 --- a/compiler/src/dotty/tools/dotc/core/GadtConstraint.scala +++ b/compiler/src/dotty/tools/dotc/core/GadtConstraint.scala @@ -193,7 +193,8 @@ sealed trait GadtState { case i => pt.paramRefs(i) case tp => tp } - + if !param.info.exists then + throw TypeError(em"illegal recursive reference involving $param") val tb = param.info.bounds tb.derivedTypeBounds( lo = substDependentSyms(tb.lo, isUpper = false), diff --git a/compiler/test/dotc/neg-best-effort-pickling.blacklist b/compiler/test/dotc/neg-best-effort-pickling.blacklist index ff02be107a8a..1c8421b44539 100644 --- a/compiler/test/dotc/neg-best-effort-pickling.blacklist +++ b/compiler/test/dotc/neg-best-effort-pickling.blacklist @@ -13,6 +13,7 @@ curried-dependent-ift.scala i17121.scala illegal-match-types.scala i13780-1.scala +i20317a.scala # semantic db generation fails in the first compilation i1642.scala diff --git a/tests/neg/i20317.scala b/tests/neg/i20317.scala new file mode 100644 index 000000000000..e9d8599b9fc1 --- /dev/null +++ b/tests/neg/i20317.scala @@ -0,0 +1,3 @@ +type Foo[A] = A + +def foo[A <: Foo[A]]: Unit = () // error // error diff --git a/tests/neg/i20317a.scala b/tests/neg/i20317a.scala new file mode 100644 index 000000000000..d7b8b66eb80e --- /dev/null +++ b/tests/neg/i20317a.scala @@ -0,0 +1,5 @@ +type SemigroupStructural[A] = + A & { def combine(a: A): A } +def combineAll[A <: SemigroupStructural[A]]( + i: A, l: List[A] +): A = l.foldLeft(i)(_.combine(_)) // error