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 = uninitialized
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 @@ -3158,10 +3158,26 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3158
3158
val usingParamAccessors = cls.paramAccessors.filter(_.is(Given ))
3159
3159
val paramScope = newScopeWith(usingParamAccessors* )
3160
3160
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
+
3161
3174
val rhs = implicitArgTree(target, cdef.span,
3162
3175
where = i " inferring the implementation of the deferred ${dcl.showLocated}"
3163
3176
)(using searchCtx)
3164
3177
3178
+ if responsibleForImports == null then
3179
+ depRecorder._responsibleForImports = null
3180
+
3165
3181
val impl = dcl.copy(cls,
3166
3182
flags = dcl.flags &~ (HasDefault | Deferred ) | Final | Override ,
3167
3183
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