Skip to content

Recursive match type failing to expand completely #6322

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
nicolasstucki opened this issue Apr 16, 2019 · 1 comment
Closed

Recursive match type failing to expand completely #6322

nicolasstucki opened this issue Apr 16, 2019 · 1 comment
Assignees

Comments

@nicolasstucki
Copy link
Contributor

type F[N <: Int] = N match {
  case 1 => Int => Int
  case 2 => F[1]
}

val s: F[2] = ???
s.apply(4)

fails Ycheck:posttyper with

checking tests/run-with-compiler/i6281.scala after phase posttyper
exception while typing Test.s.$asInstanceOf$[Test.F[Int(1)]].apply(4) of class class dotty.tools.dotc.ast.Trees$Apply # 1259
exception while typing @scala.annotation.internal.SourceFile("tests/run-with-compiler/i6281.scala") 
  final module
 class Test() extends Object(), _root_.scala.Serializable { this: Test.type => 
  private def writeReplace(): AnyRef = 
    new scala.runtime.ModuleSerializationProxy(classOf[Test.type])
  type F[N >: Nothing <: Int] = 
    N match 
      {
        case 1.type => Function1[Int, Int]
        case 2.type => Test.F[1.type]
      }
  val s: Test.F[2.type] = ???
  Test.s.$asInstanceOf$[Test.F[Int(1)]].apply(4)
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 1269
exception while typing package <empty> {
  import scala.quoted._
  final lazy module val Test: Test = new Test()
  @scala.annotation.internal.SourceFile("tests/run-with-compiler/i6281.scala") 
    final module
   class Test() extends Object(), _root_.scala.Serializable { this: Test.type =>
     
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(classOf[Test.type])
    type F[N >: Nothing <: Int] = 
      N match 
        {
          case 1.type => Function1[Int, Int]
          case 2.type => Test.F[1.type]
        }
    val s: Test.F[2.type] = ???
    Test.s.$asInstanceOf$[Test.F[Int(1)]].apply(4)
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 1270
*** error while checking tests/run-with-compiler/i6281.scala after phase posttyper ***
java.lang.AssertionError: assertion failed: Found:    Int(4)
Required: T1
tree = 4 while compiling tests/run-with-compiler/i6281.scala
exception occurred while compiling tests/run-with-compiler/i6281.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Found:    Int(4)
Required: T1
tree = 4
        at scala.Predef$.assert(Predef.scala:223)
        at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:461)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:329)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:784)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:782)
        at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:550)
        at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:593)
        at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:371)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:685)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:783)
        at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:856)
        at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$9(Applications.scala:885)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2262)
        at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$1(Applications.scala:886)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:825)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:931)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:823)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:87)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2078)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2132)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:267)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2166)
        at dotty.tools.dotc.reporting.TraceSyntax.apply(trace.scala:56)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2159)
@nicolasstucki
Copy link
Contributor Author

This might be the cause of #6281

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

No branches or pull requests

2 participants