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

pattern with inferred type params plus recursive call: crash #3880

Closed
scabug opened this Issue Sep 29, 2010 · 3 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Sep 29, 2010

[Deleted original report]

I have run into this again and it's going to be a problem for improving the pattern matcher's type parameter handling. I don't think it actually has anything to do with tailcalls (although it may), I think that's only where it's being revealed, and it originates in the typer. So I'm reassigning to scala_reviewer to see if it can get another look.

Here is a distillation of the problem.

abstract class Bar[+B] {
}
abstract class C1[+B] extends Bar[B] {  
  private[this] def g(x: C1[B]): Unit = ()

  // this method is fine: notice that it allows the call to g,
  // which requires C1[B], even though we matched on C1[_].
  // (That is good news.)
  private[this] def f1(x: Bar[B]): Unit = x match {
    case x: C1[_] => g(x)
  }
  // this one crashes.
  private[this] def f2(x: Bar[B]): Unit = x match {
    case x: C1[_] => f2(x)
  }
}

The crash:

Exception in thread "main" scala.tools.nsc.symtab.Types$$TypeError: type mismatch;
 found   : C1[_]
 required: Bar[B]
 at scala.tools.nsc.typechecker.Contexts$$Context.error(Contexts.scala:280)
 at scala.tools.nsc.typechecker.Infer$$Inferencer.error(Infer.scala:203)
 at scala.tools.nsc.typechecker.Infer$$Inferencer.typeError(Infer.scala:213)
 at scala.tools.nsc.typechecker.Infer$$Inferencer.typeErrorTree(Infer.scala:228)
 at scala.tools.nsc.typechecker.Typers$$Typer.adapt(Typers.scala:1018)
 at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:4186)
 at scala.tools.nsc.typechecker.Typers$$Typer.typedArg(Typers.scala:2209)
 at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedArgs$$3.apply(Typers.scala:2220)  
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Sep 29, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3880?orig=1
Reporter: @paulp
Other Milestones: 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Oct 5, 2010

@adriaanm said:
scala solutions will save the day

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 20, 2012

@retronym said:
Works now, test case:

scala/scala#591

@scabug scabug closed this May 21, 2012

@scabug scabug added the patmat label Apr 7, 2017

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment