Compiler version
3.2.1
Minimized code
import scala.language.dynamics
import scala.collection._
object ImplicitDynamics {
type JsonPrimitive = String | Int | Double | Boolean | None.type
type SomeJson = mutable.Map[String, JsonPrimitive]
def obj(values: (String, JsonPrimitive)*): SomeJson =
(new mutable.HashMap[String, JsonPrimitive]()).addAll(values)
implicit class Json(val underlying: SomeJson) extends Dynamic {
def selectDynamic(key: String): JsonPrimitive = underlying(key)
}
}
import ImplicitDynamics._
println(Json(obj("name" -> "John", "age" -> 42)).name)
println(obj("name" -> "John", "age" -> 42).apply("name"))
println(obj("name" -> "John", "age" -> 42).name) // <-- Doesn't compile
Output
The last line doesn't compile.
Expectation
The list line should print the same result as previous 2.
I stuck with that during adding Scala 3 support for the dijon project in the following PR: jvican/dijon#202
Compiler version
3.2.1
Minimized code
Output
The last line doesn't compile.
Expectation
The list line should print the same result as previous 2.
I stuck with that during adding Scala 3 support for the dijon project in the following PR: jvican/dijon#202