Skip to content

Variance not copied into enum case class type parameters #9260

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
bishabosha opened this issue Jun 29, 2020 · 0 comments · Fixed by #9709
Closed

Variance not copied into enum case class type parameters #9260

bishabosha opened this issue Jun 29, 2020 · 0 comments · Fixed by #9709
Assignees
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Jun 29, 2020

Minimized code

package asts

enum Ast[-T >: Null]:
  case DefDef()

trait AstImpl[T >: Null]:
  type Ast = asts.Ast[T]
  type DefDef = Ast.DefDef[T]
end AstImpl

object untpd extends AstImpl[Null]:

  def DefDef(ast: Ast): DefDef = ast match
    case ast: DefDef => ast

end untpd

Output

-- Warning: Ast.scala:24:9 -----------------------------------------------------
24 |    case ast: DefDef => ast
   |         ^^^^^^^^^^^
   |        the type test for asts.untpd.DefDef cannot be checked at runtime
1 warning found

Expectation

compile as in 0.24.0-RC1

Notes

if we instead explicitly copy the variance from the parent to the case, then the warning goes away:

enum Ast[-T >: Untyped]:
  // case DefDef()
  case DefDef[-T >: Untyped]() extends Ast[T]
@bishabosha bishabosha changed the title Upper bound not copied into enum case class constructors Upper bound not copied into enum case class type parameters Jun 29, 2020
@bishabosha bishabosha changed the title Upper bound not copied into enum case class type parameters Upper bound + Variance not copied into enum case class type parameters Jun 29, 2020
@bishabosha bishabosha changed the title Upper bound + Variance not copied into enum case class type parameters Variance not copied into enum case class type parameters Jun 29, 2020
@anatoliykmetyuk anatoliykmetyuk self-assigned this Jul 3, 2020
@bishabosha bishabosha mentioned this issue Jul 8, 2020
22 tasks
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 2, 2020
bishabosha added a commit that referenced this issue Sep 18, 2020
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 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.

4 participants