From 15b90b1e12add3e02121c9000f887e785ba4ae88 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 11 Jan 2021 19:53:47 +0100 Subject: [PATCH] Fix hoisting supercall arguments from primary constructor Fix hoisting of supercall arguments from primary constructor of a class with var parameters. Fixes #11045 --- compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala | 2 +- tests/pos/i11045.scala | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i11045.scala diff --git a/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala b/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala index 219e51050961..084b0793607d 100644 --- a/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala +++ b/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala @@ -67,7 +67,7 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase val constr = cdef.symbol lazy val origParams = // The parameters that can be accessed in the supercall if (constr == cls.primaryConstructor) - cls.info.decls.filter(d => d.is(TypeParam) || d.is(ParamAccessor)) + cls.info.decls.filter(d => d.is(TypeParam) || d.is(ParamAccessor) && !d.isSetter) else allParamSyms(cdef) diff --git a/tests/pos/i11045.scala b/tests/pos/i11045.scala new file mode 100644 index 000000000000..da5d66a7a633 --- /dev/null +++ b/tests/pos/i11045.scala @@ -0,0 +1,2 @@ +abstract class Foo(x: Any) +class Boom(var x: Unit, y: Unit) extends Foo((x: Int) => x) \ No newline at end of file