diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 49b91a37c43f..a78e8ea5abda 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2289,7 +2289,7 @@ class Typer extends Namer var added: Tree = TypeTree(parent).withSpan(cdef.nameSpan.focus) if psym.is(Trait) && psym.primaryConstructor.info.takesImplicitParams then // classes get a constructor separately using a different context - added = ensureConstrCall(cls, added) + added = ensureConstrCall(cls, added)(using superCtx) added :: parentTrees(parents1, ptrees) case _ => ptrees diff --git a/tests/run/i11966.check b/tests/run/i11966.check new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/run/i11966.check @@ -0,0 +1 @@ +1 diff --git a/tests/run/i11966.scala b/tests/run/i11966.scala new file mode 100644 index 000000000000..184e68f7599c --- /dev/null +++ b/tests/run/i11966.scala @@ -0,0 +1,17 @@ +trait A[T]: + def f: T + +trait B[T: A]: + println(summon[A[T]].f) + +trait C[T: A] extends B[T] + +given a1: A[Int] with + def f = 1 + +class D extends C[Int]: + given a2: A[Int] with + def f = 2 + +@main def Test = D() +