Welcome to Scala 2.13.18 (OpenJDK 64-Bit Server VM, Java 21.0.12).
Type in expressions for evaluation. Or try :help.
scala> val a = java.time.LocalDate.now()
val a: java.time.LocalDate = 2026-09-20
scala> a.synchronized(a)
val res0: java.time.LocalDate = 2026-09-20
$ jshell
| Welcome to JShell -- Version 21.0.12
| For an introduction type: /help intro
jshell> var a = java.time.LocalDate.now()
a ==> 2026-09-20
jshell> int b() { synchronized(a) { return 2; } }
| Warning:
| attempt to synchronize on an instance of a value-based class
| int b() { synchronized(a) { return 2; } }
| ^---------------------------^
| created method b()
Reproduction steps
Scala version: 2.13.18
Problem
expect warning same as Java
Note