Skip to content

Commit 19b0ca8

Browse files
bishaboshajulienrf
authored andcommitted
mark value classes as scala 2 only
1 parent ab04353 commit 19b0ca8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

_overviews/core/value-classes.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ partof: value-classes
77
languages: [ja, zh-cn]
88

99
permalink: /overviews/core/:title.html
10+
scala2: true
11+
versionSpecific: true
1012
---
1113

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

1416
## Introduction
1517

@@ -212,7 +214,7 @@ Note that local classes, traits, and objects are not allowed either, as in the f
212214
...
213215
}
214216
}
215-
217+
216218
Local.scala:3: error: implementation restriction: nested class is not allowed in value class
217219
class Local
218220
^
@@ -272,3 +274,5 @@ but this is allowed because the enclosing object is top-level:
272274
object Outer {
273275
class Inner(val x: Int) extends AnyVal
274276
}
277+
278+
[opaques]: {% link _overviews/scala3-book/types-opaque-types.md %}

_overviews/scala3-book/types-opaque-types.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ languages: [ru, zh-cn]
66
num: 55
77
previous-page: types-variance
88
next-page: types-structural
9+
scala3: true
10+
versionSpecific: true
911
---
1012

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

1316
## Abstraction Overhead
1417

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

143146

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

0 commit comments

Comments
 (0)