Skip to content

Commit 397416f

Browse files
oderskymichelou
authored andcommitted
Use supercall context when calling inserted super traits
This is analgous to inserting a call for a superclass. In either case we should not be able to see local class definitions.
1 parent c1588d4 commit 397416f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ class Typer extends Namer
22902290
var added: Tree = TypeTree(parent).withSpan(cdef.nameSpan.focus)
22912291
if psym.is(Trait) && psym.primaryConstructor.info.takesImplicitParams then
22922292
// classes get a constructor separately using a different context
2293-
added = ensureConstrCall(cls, added)
2293+
added = ensureConstrCall(cls, added)(using superCtx)
22942294
added :: parentTrees(parents1, ptrees)
22952295
case _ =>
22962296
ptrees

tests/run/i11966.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

tests/run/i11966.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
trait A[T]:
2+
def f: T
3+
4+
trait B[T: A]:
5+
println(summon[A[T]].f)
6+
7+
trait C[T: A] extends B[T]
8+
9+
given a1: A[Int] with
10+
def f = 1
11+
12+
class D extends C[Int]:
13+
given a2: A[Int] with
14+
def f = 2
15+
16+
@main def Test = D()
17+

0 commit comments

Comments
 (0)