Skip to content

Conversation

EugeneFlesselle
Copy link
Contributor

See commit messages

Before the addition of `SymDenotation#mayDeriveFrom`,
tests/neg/i17132.min.scala was unsoundly accepted without a type error
because `R[T]` is reduced to `Any` where `T <: P[Any]`
by testing `provablyDisjointClasses` before `P` is added as a baseClass of `Q`.

Now, a recursion overflows occurs because:
- reducing `R[T] := T match case Q[t] => R[t]; case ...` requires
- proving `T` disjoint from `Q[t]` where `T <: P[Any]`, which asks
- whether existsCommonBaseTypeWithDisjointArguments, which requires
- normalizing the type arg to the base class P for the class Q, i.e. R[t]
- ...

In short, despite the use of the pending set in provablyDisjoint, diverging is
still possible when there is "cycle" in the type arguments in the base classes,
(and where the pending set is thus reset for a separate normalization problem).

One could attempt to add some more logic to detect these loops
s.t. they are considered "stuck", as opposed to reporting an error.
But it isn't clear that there are any concrete motivations for this.
For some reason, the derivesFrom issue was only observable in the minimization.
The original test case diverges similarly to the previous description,
but only when attempting normalizing during CodeGen...
@EugeneFlesselle EugeneFlesselle merged commit ca400bd into scala:main Aug 29, 2025
43 checks passed
@EugeneFlesselle EugeneFlesselle deleted the mayDeriveFrom branch August 29, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"children of trait were already queried before class was discovered" due to match type used
2 participants