diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 0c5697a26fce..2eec6579492b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -778,6 +778,8 @@ object Checking { } clParamAccessors match { case param :: params => + if (defn.isContextFunctionType(param.info)) + report.error("value classes are not allowed for context function types", param.srcPos) if (param.is(Mutable)) report.error(ValueClassParameterMayNotBeAVar(clazz, param), param.srcPos) if (param.info.isInstanceOf[ExprType]) diff --git a/tests/neg/i22752.scala b/tests/neg/i22752.scala new file mode 100644 index 000000000000..5c93b3ccbd68 --- /dev/null +++ b/tests/neg/i22752.scala @@ -0,0 +1,4 @@ +class Inner(body: Int ?=> Int) extends AnyVal: // error + def rescue: Int ?=> Int = ??? + +class Inner2(body: Int => Int) extends AnyVal // ok