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 = uninitialized
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 @@ -3158,10 +3158,26 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
31583158 val usingParamAccessors = cls.paramAccessors.filter(_.is(Given ))
31593159 val paramScope = newScopeWith(usingParamAccessors* )
31603160 val searchCtx = ctx.outer.fresh.setScope(paramScope)
3161+
3162+ // Before losing the reference to ctx.owner
3163+ // when calling implicitArgTree with searchCtx,
3164+ // let's store ctx.owner as the fallback "responsibleForImports"
3165+ // in DependencyRecorder. That way, if we end up recording any dependencies
3166+ // we use ctx.owner as the "fromClass" rather than emitting a warning
3167+ // (because ctx.compilationUnit.tpdTree is still EmptyTree during typer).
3168+ // For example, to record mirror dependencies, see i23049.
3169+ val depRecorder = ctx.compilationUnit.depRecorder
3170+ val responsibleForImports = depRecorder._responsibleForImports
3171+ if responsibleForImports == null then
3172+ depRecorder._responsibleForImports = ctx.owner
3173+
31613174 val rhs = implicitArgTree(target, cdef.span,
31623175 where = i " inferring the implementation of the deferred ${dcl.showLocated}"
31633176 )(using searchCtx)
31643177
3178+ if responsibleForImports == null then
3179+ depRecorder._responsibleForImports = null
3180+
31653181 val impl = dcl.copy(cls,
31663182 flags = dcl.flags &~ (HasDefault | Deferred ) | Final | Override ,
31673183 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