Skip to content

Unsoundness when matching on a wildcard with bad bounds at definition site #15569

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

Closed
s5bug opened this issue Jul 1, 2022 · 1 comment · Fixed by #15571
Closed

Unsoundness when matching on a wildcard with bad bounds at definition site #15569

s5bug opened this issue Jul 1, 2022 · 1 comment · Fixed by #15571
Milestone

Comments

@s5bug
Copy link

s5bug commented Jul 1, 2022

Compiler version

3.1.3, 3.2.0-RC1

Minimized code

trait Foo[X >: Any <: Nothing]

def andThenSub[A, B, C](f: A <:< B, g: B <:< C): A <:< C =
  f.andThen(g)

(None: Option[Foo[?]]) match {
  case _: Option[Foo[t]] =>
    val unsound: Any <:< Nothing = andThenSub[Any, t, Nothing](summon, summon)
    unsound("hi :)")
}

Output

java.lang.ClassCastException: class java.lang.String cannot be cast to class scala.runtime.Nothing$

Expectation

A compilation error on the definition of Foo.

Possibly related to #15568?

@s5bug s5bug added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 1, 2022
@s5bug s5bug changed the title Unsoundness when hiding a wildcard behind an alias Unsoundness when matching on a wildcard with bad bounds at definition site Jul 1, 2022
@s5bug
Copy link
Author

s5bug commented Jul 1, 2022

Apologies, old title was from before I minimized away the alias :)

odersky added a commit to dotty-staging/dotty that referenced this issue Jul 2, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue Jul 2, 2022
@griggt griggt removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jul 16, 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants