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

mark value classes as scala 2 only #2863

Merged
merged 1 commit into from
Jul 17, 2023
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
8 changes: 6 additions & 2 deletions _overviews/core/value-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ partof: value-classes
languages: [ja, zh-cn]

permalink: /overviews/core/:title.html
scala2: true
versionSpecific: true
---

**Mark Harrah**
In Scala 3, a similar result can be achieved with [opaque types][opaques].

## Introduction

Expand Down Expand Up @@ -212,7 +214,7 @@ Note that local classes, traits, and objects are not allowed either, as in the f
...
}
}

Local.scala:3: error: implementation restriction: nested class is not allowed in value class
class Local
^
Expand Down Expand Up @@ -272,3 +274,5 @@ but this is allowed because the enclosing object is top-level:
object Outer {
class Inner(val x: Int) extends AnyVal
}

[opaques]: {% link _overviews/scala3-book/types-opaque-types.md %}
6 changes: 5 additions & 1 deletion _overviews/scala3-book/types-opaque-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ languages: [ru, zh-cn]
num: 55
previous-page: types-variance
next-page: types-structural
scala3: true
versionSpecific: true
---

Scala 3 _Opaque type aliases_ provide type abstractions without any **overhead**.
_Opaque type aliases_ provide type abstraction without any **overhead**.
In Scala 2, a similar result could be achieved with [value classes][value-classes].

## Abstraction Overhead

Expand Down Expand Up @@ -142,3 +145,4 @@ As illustrated above, opaque types are convenient to use, and integrate very wel


[extension]: {% link _overviews/scala3-book/ca-extension-methods.md %}
[value-classes]: {% link _overviews/core/value-classes.md %}