无形2.3.3LabelledGeneric
在以下案例类上运行时返回一个奇怪的结果:
scala> case class Foo(`$eq`: Int)
defined class Foo
scala> LabelledGeneric[Foo]
res0: shapeless.LabelledGeneric[Foo]{type Repr = Int with shapeless.labelled.KeyTag[Symbol with shapeless.tag.Tagged[String("=")],Int] :: shapeless.HNil} = shapeless.LabelledGeneric$$anon$1@1ac7dbd3
注意返回的标签是字面意思=
代替$eq
.
这种行为是无形的怪癖还是其他什么?是否还有其他标识符名称会导致奇怪的行为?
我需要这个来进行 MongoDB 序列化,这对我来说是一个非常头疼的问题......
根据 Alexey 在 Q 中的评论,这是 Shapeless 中的一个“功能”,因为 scala/java 互操作的工作方式。后者的解释在丹尼尔·斯皮瓦克博客文章 http://www.codecommit.com/blog/java/interop-between-java-and-scala在“运算符和重载”下。
根据博客,受此影响的运营商列表是:
op Compiles To
= $eq
> $greater
< $less
+ $plus
- $minus
* $times
/ div
! $bang
@ $at
# $hash
% $percent
^ $up
& $amp
~ $tilde
? $qmark
| $bar
\ $bslash
: $colon
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)