Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow export statements in AnyVal #21653

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/run/export-anyval.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from export
12 changes: 12 additions & 0 deletions tests/run/export-anyval.scala
Original file line number Diff line number Diff line change
@@ -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)

Loading