diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 7f5ac955fa12..700bd483ff38 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -727,7 +727,7 @@ object Checking { report.error(ValueClassesMayNotDefineNonParameterField(clazz, stat.symbol), stat.srcPos) case _: DefDef if stat.symbol.isConstructor => report.error(ValueClassesMayNotDefineASecondaryConstructor(clazz, stat.symbol), stat.srcPos) - case _: MemberDef | _: Import | EmptyTree => + case _: MemberDef | _: Import | _: Export | EmptyTree => // ok case _ => report.error(ValueClassesMayNotContainInitalization(clazz), stat.srcPos) diff --git a/tests/run/export-anyval.check b/tests/run/export-anyval.check new file mode 100644 index 000000000000..1c2f472bb006 --- /dev/null +++ b/tests/run/export-anyval.check @@ -0,0 +1 @@ +Hello from export \ No newline at end of file diff --git a/tests/run/export-anyval.scala b/tests/run/export-anyval.scala new file mode 100644 index 000000000000..26fb2230781d --- /dev/null +++ b/tests/run/export-anyval.scala @@ -0,0 +1,12 @@ +class Foo(val x: String) + + +class Bar(val y: Foo) extends AnyVal: + export y.* + def foo: String = x +end Bar + +@main def Test = + val a = Bar(Foo("Hello from export")) + println(a.foo) +