File tree 3 files changed +29
-1
lines changed
compiler/src/dotty/tools/dotc
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -577,7 +577,7 @@ class DependencyRecorder {
577
577
clazz
578
578
}
579
579
580
- private var _responsibleForImports : Symbol = uninitialized
580
+ private [dotc] var _responsibleForImports : Symbol | Null = null
581
581
582
582
/** Top level import dependencies are registered as coming from a first top level
583
583
* 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
3205
3205
val usingParamAccessors = cls.paramAccessors.filter(_.is(Given ))
3206
3206
val paramScope = newScopeWith(usingParamAccessors* )
3207
3207
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
+
3208
3221
val rhs = implicitArgTree(target, cdef.span,
3209
3222
where = i " inferring the implementation of the deferred ${dcl.showLocated}"
3210
3223
)(using searchCtx)
3211
3224
3225
+ if responsibleForImports == null then
3226
+ depRecorder._responsibleForImports = null
3227
+
3212
3228
val impl = dcl.copy(cls,
3213
3229
flags = dcl.flags &~ (HasDefault | Deferred ) | Final | Override ,
3214
3230
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