Skip to content

Harden GADT constraint handling to survive illegal F-bounds #20325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/GadtConstraint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/neg-best-effort-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/neg/i20317.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Foo[A] = A

def foo[A <: Foo[A]]: Unit = () // error // error
5 changes: 5 additions & 0 deletions tests/neg/i20317a.scala
Original file line number Diff line number Diff line change
@@ -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
Loading