Skip to content

Compiler crash with residual type block after erasure #6210

Closed
@biboudis

Description

@biboudis

#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'    

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions