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

Detect cyclic dependencies when loading modules #13178

Merged
merged 1 commit into from
Aug 2, 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
18 changes: 12 additions & 6 deletions compiler/src/dotty/tools/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,18 @@ object Splicer {

private def interpretedStaticMethodCall(moduleClass: Symbol, fn: Symbol)(implicit env: Env): List[Object] => Object = {
val (inst, clazz) =
if (moduleClass.name.startsWith(str.REPL_SESSION_LINE))
(null, loadReplLineClass(moduleClass))
else {
val inst = loadModule(moduleClass)
(inst, inst.getClass)
}
try
if (moduleClass.name.startsWith(str.REPL_SESSION_LINE))
(null, loadReplLineClass(moduleClass))
else {
val inst = loadModule(moduleClass)
(inst, inst.getClass)
}
catch
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

val name = fn.name.asTermName
val method = getMethod(clazz, name, paramsSig(fn))
Expand Down
21 changes: 21 additions & 0 deletions tests/neg-macros/i12788/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import scala.quoted.*

class InlinedInt[T <: Int]

object DFType:
trait Width[T]:
type Out <: Int
transparent inline given [T]: Width[T] = ${ getWidthMacro[T] }
def getWidthMacro[T](using Quotes, Type[T]): Expr[Width[T]] =
'{
new Width[T] {
type Out = 1
}
}

trait DFBits[W <: Int]
object DFBits extends DFBitsCompanion

trait DFToken[T]
extension [T](token: DFToken[T])(using w: DFType.Width[T])
def width: InlinedInt[w.Out] = ???
4 changes: 4 additions & 0 deletions tests/neg-macros/i12788/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// nopos-error
trait DFBitsCompanion:
type Token[W <: Int] = DFToken[DFType.DFBits[W]]
extension [LW <: Int](lhs: DFType.DFBits.Token[LW]) def foo: Unit = lhs.width