Skip to content

Error while typing nested pattern match  #4198

@nicolasstucki

Description

@nicolasstucki
class Foo {
  def foo(x: Any): Unit = {
    x match {
      case y: Bar[_] =>
        y.value match {
          case value: Bar[_] => // here x is an instance of Bar[Bar[_]]
          case _ =>
        }
    }
  }
}

class Bar[T] {
  def value: T = ???
}

fails while Ychecking with

checking Foo.scala after phase MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes}
exception while typing _ of class class dotty.tools.dotc.ast.Trees$Ident # 31
exception while typing y.value match 
  {
    case value @ _: Bar[_] @_ => 
      ()
    case _ => 
      ()
  } of class class dotty.tools.dotc.ast.Trees$Match # 212
exception while typing {
  y.value match 
    {
      case value @ _: Bar[_] @_ => 
        ()
      case _ => 
        ()
    }
} of class class dotty.tools.dotc.ast.Trees$Block # 213
...
...
Exception in thread "main" java.lang.AssertionError: assertion failed: undefined symbol type _
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.transform.TreeChecker$Checker.assertDefined(TreeChecker.scala:190)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedIdent(TreeChecker.scala:307)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1752)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1822)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:113)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:269)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1854)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1850)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1862)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:257)
	at dotty.tools.dotc.typer.Typer.typedPattern(Typer.scala:1926)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedCase$1(Typer.scala:1043)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:1002)
	at dotty.tools.dotc.transform.TreeChecker$Checker.super$typedCase(TreeChecker.scala:409)
	at dotty.tools.dotc.transform.TreeChecker$Checker.$anonfun$typedCase$2(TreeChecker.scala:409)
	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:180)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedCase(TreeChecker.scala:408)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedCases$3(Typer.scala:998)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions