标记为泛型,包含$ eq [英] Labelled Generic containing `$eq`
问题描述
Shapeless 2.3.3 LabelledGeneric
在以下案例类中运行时返回奇怪的结果:
Shapeless 2.3.3 LabelledGeneric
returns a curious result when run on the following case class:
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
.
Note the label returned is literally =
instead of $eq
.
此行为是无形的怪癖还是其他?还有其他标识符名称会导致异常行为吗?
Is this behaviour a quirk of shapeless or something else? Are there other identifier names that result in weird behaviour?
我需要MongoDB序列化,这让我头疼……
I require this for MongoDB serialization and this kind of a major headache for me ...
推荐答案
根据Q中Alexey的评论,由于scala/java互操作的工作方式,这是Shapeless的功能".后者在 Daniel Spiewak的污点文章中进行了解释操作员和超负荷工作".
As per Alexey's comment in the Q, this is a 'feature' in Shapeless, because of the way scala/java interop works. The latter is explained in Daniel Spiewak's blot post under "operators and overaloading".
这会影响每个博客的运营商列表:
The list of operators, per the blog, that this affects are:
op Compiles To
= $eq
> $greater
< $less
+ $plus
- $minus
* $times
/ div
! $bang
@ $at
# $hash
% $percent
^ $up
& $amp
~ $tilde
? $qmark
| $bar
\ $bslash
: $colon
这篇关于标记为泛型,包含$ eq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!