Skip to content

Backport "Allow export statements in AnyVal" to LTS #7

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

Merged
merged 2 commits into from
Dec 6, 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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import printing.Formatting.hl
import config.Printers

import scala.annotation.internal.sharable
import dotty.tools.dotc.util.SrcPos

object desugar {
import untpd.*
Expand Down
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 @@ -708,7 +708,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