Skip to content

Conversation

Linyxus
Copy link
Contributor

@Linyxus Linyxus commented Aug 17, 2022

#15851 merges a nice fix for issue #15743. However, in some cases the usage of GADT constraints is not recorded so the GADT cast is not inserted. This PR tries to cover more cases where GADTused should be set.

@Linyxus Linyxus requested a review from dwijnand August 17, 2022 13:51
@Linyxus
Copy link
Contributor Author

Linyxus commented Aug 17, 2022

Note that this PR still cannot cover all the cases. For example, the following code still fails the tree checker:

trait Tag[S]
case class TupTag[A, T <: Tuple]() extends Tag[A *: T]

def tupleId[T <: Tuple](x: T): x.type = x

def foo[S](x: S, ev: Tag[S]) = ev.match {
  case _: TupTag[a, t] =>
    val t1: t = tupleId(x.tail)
}

It seems that the cause of the failure is related to type inference. In the subtype trace I cannot find a place where we can record the usage of GADT constraints for match type reduction. I am not 100% sure about what happens.

@Linyxus Linyxus force-pushed the matchtype-gadtusage-back branch from e53d411 to b706e85 Compare August 17, 2022 13:55
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

@dwijnand dwijnand merged commit 30b41c1 into scala:main Aug 17, 2022
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
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.

3 participants