-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unresolved symbols: value p1(line 15) when pickling #6988
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
Comments
@eed3si9n : I played with the example in #7009, it seems to work after some tweaks. The original code does not work because /cc: @nicolasstucki I just checked, ScalaTest does not use |
In the code where I came across this issue, my def enclosingParamList: Seq[Seq[Symbol]] = {
nearestEnclosingMethod(rootContext.owner) match {
case IsDefDefSymbol(x) =>
x.tree.paramss map { _ map {
_.symbol
}}
case IsClassDefSymbol(x) =>
x.tree.constructor.paramss map { _ map {
_.symbol
}}
}
} |
@eed3si9n Thanks for the pointer, it seems to be pretty useful. /cc: @nicolasstucki what about just keep |
May be related: #7008 |
I played more with inline def debug: Unit = ${Macros.debugImpl}
object Macros {
import scala.quoted._
import scala.tasty._
def debugImpl given (qctx: QuoteContext): Expr[Unit] = {
import qctx.tasty._
def nearestEnclosingDef(owner: Symbol): Symbol =
owner match {
case IsDefDefSymbol(x) => x
case IsClassDefSymbol(x) => x
case _ => nearestEnclosingDef(owner.owner)
}
def trace(sym: Symbol): Term = {
val ref = Ref(sym)
'{ println(${ref.seal}) }.unseal
}
val stats = nearestEnclosingDef(rootContext.owner) match {
case IsDefDefSymbol(x) =>
x.tree.paramss.flatten map { param =>
trace(param.symbol)
}
case IsClassDefSymbol(x) =>
x.tree.constructor.paramss.flatten map { param =>
trace(x.field(param.symbol.name).get)
}
}
Block(stats, '{()}.unseal).seal.cast[Unit]
}
} object Test {
def main(args: Array[String]): Unit = {
new Foo("hello", 35, false)
bar("world", 100, true)
}
def bar(a1: String, a2: Long, a3: Boolean): Unit = { // error: cyclic reference without explicit return type
debug // error: crash
}
class Foo(p1: String, p2: Long, p3: Boolean) {
debug
}
} stack tracejava.lang.AssertionError: assertion failed: undefined symbol val a1#6174, ower = method bar, defined = Set(val a2#4091, val a3#4092, val a1#4090), at line 18 while compiling tests/run-macros/i6988b/Test_2.scala Fatal compiler crash when compiling: tests/run-macros/i6988b: assertion failed: undefined symbol val a1#6174, ower = method bar, defined = Set(val a2#4091, val a3#4092, val a1#4090), at line 18 dotty.DottyPredef$.assertFail(DottyPredef.scala:16) dotty.tools.dotc.transform.TreeChecker$Checker.assertDefined(TreeChecker.scala:194) dotty.tools.dotc.transform.TreeChecker$Checker.typedIdent(TreeChecker.scala:320) dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1985) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2060) dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124) dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:282) dotty.tools.dotc.typer.Typer.typed(Typer.scala:2099) dotty.tools.dotc.typer.Typer.typed(Typer.scala:2111) dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:267) dotty.tools.dotc.typer.Typer.typedInlined(Typer.scala:1234) dotty.tools.dotc.transform.TreeChecker$Checker.typedInlined$$anonfun$1(TreeChecker.scala:443) dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:169) dotty.tools.dotc.transform.TreeChecker$Checker.typedInlined(TreeChecker.scala:443) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2026) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2061) dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124) dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:282) dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$3(ProtoTypes.scala:328) Meanwhile, it seems that exposing |
minimized code
Here's a macro that finds the enclosing class's constructor parameter, and picks up the first argument.
FirstArg.scala
Test1.scala
Stack trace
notes
Ref #5789
The text was updated successfully, but these errors were encountered: