File tree 3 files changed +26
-1
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -275,7 +275,20 @@ object Applications {
275
275
if (getterDenot.exists) qual.select(TermRef (qual.tpe, getterName, getterDenot))
276
276
else EmptyTree
277
277
if ! meth.isClassConstructor then
278
- selectGetter(receiver)
278
+ val res = selectGetter(receiver)
279
+ if res.isEmpty && meth.is(Given ) then
280
+ val classSym = meth.info.finalResultType.typeSymbol
281
+ if classSym.isClass && classSym.isAllOf(Given | Synthetic ) then
282
+ // `meth` is an implicit wrapper: the `given def` desugared from a
283
+ // `given C(...)` or `given C with ...` by `desugar#classDef`.
284
+ // Therefore, we can try to look for the default getters of the
285
+ // constructor of the `given class`. We find it via the `given
286
+ // def`'s result type. See #20088 and associated test cases.
287
+ val classRefTree = receiver.select(classSym)
288
+ val constructorSym = classSym.primaryConstructor.asTerm
289
+ findDefaultGetter(constructorSym, classRefTree, idx)
290
+ else res
291
+ else res
279
292
else
280
293
// default getters for class constructors are found in the companion object
281
294
val cls = meth.owner
Original file line number Diff line number Diff line change
1
+ trait Foo
2
+ trait Bar
3
+
4
+ given (using foo : Foo = new {}): Bar with {}
5
+
6
+ def Test = summon[Bar ]
Original file line number Diff line number Diff line change
1
+ trait Foo
2
+ class Bar
3
+
4
+ given (using foo : Foo = new {}): Bar ()
5
+
6
+ def Test = summon[Bar ]
You can’t perform that action at this time.
0 commit comments