Skip to content

Commit

Permalink
Merge pull request #13525 from dotty-staging/fix-#13516
Browse files Browse the repository at this point in the history
Capture missing class when loading methods
  • Loading branch information
anatoliykmetyuk authored Sep 17, 2021
2 parents dd6da26 + 5a83848 commit 3a6a949
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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)

0 comments on commit 3a6a949

Please sign in to comment.