Skip to content

Commit e216783

Browse files
committed
Add section for Java compatible enums to blogpost
1 parent 9ca016e commit e216783

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

docs/blog/_posts/2019-06-11-16th-dotty-milestone-release.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ This is our 16th scheduled release according to our
3838

3939
# What’s new in the 0.16.0-RC3 technology preview?
4040

41-
<!-- https://github.com/lampepfl/dotty/pulls?q=is%3Apr+closed%3A%3E2019-05-23+is%3Aclosed+sort%3Acomments-desc -->
42-
4341
## Syntax Change: Type Lambdas
4442

4543
We reconsider the syntax of type lambdas in an effort to provide an improved
@@ -72,7 +70,7 @@ aligns with Java's syntax.
7270
For more information please read our documentation on
7371
[Wildcards](https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html).
7472

75-
# Syntax Change: Contextual Abstractions
73+
## Syntax Change: Contextual Abstractions
7674

7775
We reconsider the syntax for contextual abstractions introducing `delegates`
7876
(formerly known as `implied`). `delegate`, in the context of contextual
@@ -131,7 +129,7 @@ With PFTs we can now achieve what we want:
131129
For those who are interested in the discussions and more test cases,
132130
[#4672](https://github.com/lampepfl/dotty/pull/4672/) introduced PFTs.
133131

134-
## lazy vals are now thread-safe by default
132+
## `lazy val`s are now thread-safe by default
135133

136134
Previously thread-safety was required using `@volatile` but that would not be
137135
consistent with Scala 2. The old behavior of non-volatile lazy vals can be
@@ -140,6 +138,31 @@ recovered by using the newly-introduced `@threadUnsafe`.
140138
For more information please read our documentation on the
141139
[threadUnsafe annotation](https://dotty.epfl.ch/docs/reference/other-new-features/threadUnsafe-annotation.html).
142140

141+
## Add support for Java-compatible enums
142+
143+
We add support for Java-compatible enumerations. The users can just extend
144+
`java.lang.Enum[T]`.
145+
146+
```scala
147+
enum A extends java.lang.Enum[A] {
148+
case MONDAY, TUESDAY, SATURDAY
149+
}
150+
151+
enum B(val gravity: Double) extends java.lang.Enum[B] {
152+
case EARTH extends B(9.8)
153+
case JUPITER extends B(100)
154+
case MOON extends B(4.3)
155+
case Foo extends B(10)
156+
}
157+
```
158+
159+
For more information please check the [test case](https://github.com/lampepfl/dotty/tree/master/tests/run/enum-java) and
160+
also the relevant PRs [#6602](https://github.com/lampepfl/dotty/pull/6602) and
161+
[#6629](https://github.com/lampepfl/dotty/pull/6629).
162+
163+
In the test, the enums are defined in the `MainScala.scala` file and used from a
164+
Java source, `Test.java`.
165+
143166
## Introducing `for` clauses for importing delegate imports by type
144167

145168
Since delegate instances can be anonymous it is not always practical to import

0 commit comments

Comments
 (0)