File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -577,7 +577,7 @@ class DependencyRecorder {
577577 clazz
578578 }
579579
580- private var _responsibleForImports : Symbol = uninitialized
580+ private [dotc] var _responsibleForImports : Symbol | Null = null
581581
582582 /** Top level import dependencies are registered as coming from a first top level
583583 * class/trait/object declared in the compilation unit. If none exists, issue a warning and return NoSymbol.
Original file line number Diff line number Diff line change @@ -3205,10 +3205,26 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
32053205 val usingParamAccessors = cls.paramAccessors.filter(_.is(Given ))
32063206 val paramScope = newScopeWith(usingParamAccessors* )
32073207 val searchCtx = ctx.outer.fresh.setScope(paramScope)
3208+
3209+ // Before losing the reference to ctx.owner
3210+ // when calling implicitArgTree with searchCtx,
3211+ // let's store ctx.owner as the fallback "responsibleForImports"
3212+ // in DependencyRecorder. That way, if we end up recording any dependencies
3213+ // we use ctx.owner as the "fromClass" rather than emitting a warning
3214+ // (because ctx.compilationUnit.tpdTree is still EmptyTree during typer).
3215+ // For example, to record mirror dependencies, see i23049.
3216+ val depRecorder = ctx.compilationUnit.depRecorder
3217+ val responsibleForImports = depRecorder._responsibleForImports
3218+ if responsibleForImports == null then
3219+ depRecorder._responsibleForImports = ctx.owner
3220+
32083221 val rhs = implicitArgTree(target, cdef.span,
32093222 where = i " inferring the implementation of the deferred ${dcl.showLocated}"
32103223 )(using searchCtx)
32113224
3225+ if responsibleForImports == null then
3226+ depRecorder._responsibleForImports = null
3227+
32123228 val impl = dcl.copy(cls,
32133229 flags = dcl.flags &~ (HasDefault | Deferred ) | Final | Override ,
32143230 info = target,
Original file line number Diff line number Diff line change 1+ trait TC [X ]
2+ object TC {
3+ given [X : scala.deriving.Mirror .ProductOf ]: TC [X ] = ???
4+ }
5+
6+ trait Base [T ] {
7+ given TC [T ] = scala.compiletime.deferred
8+ }
9+
10+ case class P (x : Int )
11+
12+ object A extends Base [P ]
You can’t perform that action at this time.
0 commit comments