Skip to content

Compiler crash with residual type block after erasure #6210

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
biboudis opened this issue Apr 2, 2019 · 0 comments
Closed

Compiler crash with residual type block after erasure #6210

biboudis opened this issue Apr 2, 2019 · 0 comments
Assignees

Comments

@biboudis
Copy link
Contributor

biboudis commented Apr 2, 2019

#5822 brought me here:

Minimal reproduction:

import scala.quoted._

object Macro {
  inline def test[A, B]: Any =
    ${ impl[A, B] }

  def impl[A : Type, B : Type]: Expr[Any] = {
    val t = '[Map[A, B]]
    '{ ???.asInstanceOf[$t] }
  }
}
object Test {
  def main(args: Array[String]): Unit = {
    val t = Macro.test[Test.type, String]
    println(t)
  }
}

-->

    def main(args: String[]): Unit = 
      {
        val t: Object = 
          {
            ???():
              {
                type evidence$1$_$1 = Int
                type evidence$2$_$1 = String
                scala.collection.immutable.Map[Int, String]
              }
          }:Object
        println(t)
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 3655
*** error while checking /Users/bibou/Projects/dotty/tests/run/iXXXX/TupleX_2.scala after phase erasure ***
java.lang.AssertionError: assertion failed: The type scala.collection.immutable.Map[Int, String] - AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class immutable)),class Map),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Int), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scala)),module Predef),type String))) of class class dotty.tools.dotc.core.Types$CachedAppliedType of tree {
  type evidence$1$_$1 = Int
  type evidence$2$_$1 = String
  scala.collection.immutable.Map[Int, String]
} : scala.collection.immutable.Map[Int, String] / class dotty.tools.dotc.ast.Trees$Block is illegal after erasure, phase = erasure while compiling /Users/bibou/Projects/dotty/tests/run/iXXXX/TupleX_2.scala
    Compilation failed for: 'tests/run/iXXXX'    
@odersky odersky closed this as completed in e505c88 Apr 5, 2019
odersky added a commit that referenced this issue Apr 5, 2019
Fix #6210: Erase type blocks in Typed trees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants