Skip to content

Commit 05b102a

Browse files
authored
Disallow context function types as value-class parameters (#23015)
Fixes #22752
2 parents 96a3c11 + 3ee5b29 commit 05b102a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ object Checking {
778778
}
779779
clParamAccessors match {
780780
case param :: params =>
781+
if (defn.isContextFunctionType(param.info))
782+
report.error("value classes are not allowed for context function types", param.srcPos)
781783
if (param.is(Mutable))
782784
report.error(ValueClassParameterMayNotBeAVar(clazz, param), param.srcPos)
783785
if (param.info.isInstanceOf[ExprType])

tests/neg/i22752.scala

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Inner(body: Int ?=> Int) extends AnyVal: // error
2+
def rescue: Int ?=> Int = ???
3+
4+
class Inner2(body: Int => Int) extends AnyVal // ok

0 commit comments

Comments
 (0)