Skip to content
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

Capture missing class when loading methods #13525

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ object Splicer {
case _: NoSuchMethodException =>
val msg = em"Could not find method ${clazz.getCanonicalName}.$name with parameters ($paramClasses%, %)"
throw new StopInterpretation(msg, pos)
case MissingClassDefinedInCurrentRun(sym) if ctx.compilationUnit.isSuspendable =>
if (ctx.settings.XprintSuspension.value)
report.echo(i"suspension triggered by a dependency on $sym", pos)
ctx.compilationUnit.suspend() // this throws a SuspendException
}

private def stopIfRuntimeException[T](thunk: => T, method: JLRMethod): T =
Expand Down
5 changes: 5 additions & 0 deletions tests/neg-macros/i13516/Persistance.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import scala.quoted.*
object Persistance:
inline def nameOf(inline e: Any): String = ${ nameOfImpl('e) }
private def nameOfImpl(e: Expr[Any])(using Quotes): Expr[String] = Expr("")
def foo(p: Versioned): Unit = {}
3 changes: 3 additions & 0 deletions tests/neg-macros/i13516/Versioned.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// nopos-error
class Versioned:
def serialize: String = Persistance.nameOf(0)