Skip to content

Crashes when calling tasty Term.show on partial function #7898

Closed
@Atry

Description

@Atry

minimized code

// Main.scala
package bugreport
import quoted._
object Main {

  def myMacroImpl(body: Expr[_])(given qctx: QuoteContext): Expr[_] = {
    import qctx.tasty.{_, given}
    val bodyTerm = body.underlyingArgument.unseal
    println(bodyTerm.show)
    bodyTerm.seal
  }

  inline def myMacro(body: => Any) <: Any = ${
    myMacroImpl('body)
  }
}
// Test1.scala
package bugreport
import org.junit.Test
import org.junit.Assert._

class Test1 {
  @Test def t1(): Unit = {
    val _ = Main.myMacro(List[PartialFunction[Int, String]]{
      case 1 => "x"
    })
  }
}

Dotty version: 0.21.0-RC1

Stack trace
java.lang.AssertionError: NoDenotation.owner
	at dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2255)
	at dotty.tools.dotc.tastyreflect.ReflectionCompilerInterface.Symbol_owner(ReflectionCompilerInterface.scala:1577)
	at dotty.tools.dotc.tastyreflect.ReflectionCompilerInterface.Symbol_owner(ReflectionCompilerInterface.scala:1577)
	at scala.tasty.reflect.SymbolOps$symbolOps$.owner(SymbolOps.scala:20)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printAnnotation(SourceCodePrinter.scala:1231)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTypeOrAnnots$1(SourceCodePrinter.scala:432)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree$$anonfun$8(SourceCodePrinter.scala:440)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.inParens(SourceCodePrinter.scala:74)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree(SourceCodePrinter.scala:441)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printQualTree(SourceCodePrinter.scala:530)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree(SourceCodePrinter.scala:475)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree$$anonfun$9(SourceCodePrinter.scala:453)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.inParens(SourceCodePrinter.scala:74)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree(SourceCodePrinter.scala:454)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTrees$$anonfun$1(SourceCodePrinter.scala:639)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printSeparated$3(SourceCodePrinter.scala:628)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printList(SourceCodePrinter.scala:634)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTrees(SourceCodePrinter.scala:639)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree(SourceCodePrinter.scala:503)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree$$anonfun$8(SourceCodePrinter.scala:428)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.inParens(SourceCodePrinter.scala:74)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree(SourceCodePrinter.scala:441)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTrees$$anonfun$1(SourceCodePrinter.scala:639)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printSeparated$3(SourceCodePrinter.scala:628)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printList(SourceCodePrinter.scala:634)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTrees(SourceCodePrinter.scala:639)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree$$anonfun$5(SourceCodePrinter.scala:396)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.inParens(SourceCodePrinter.scala:74)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTree(SourceCodePrinter.scala:396)
	at scala.tasty.reflect.SourceCodePrinter.showTree(SourceCodePrinter.scala:12)
	at scala.tasty.reflect.PrinterOps$TreeShowDeco.show(PrinterOps.scala:20)
	at scala.tasty.reflect.PrinterOps$TreeShowDeco.show(PrinterOps.scala:16)
	at bugreport.Main$.myMacroImpl(Main.scala:8)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions