@@ -238,7 +238,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
238
238
* gets the `hashCode` method:
239
239
*
240
240
* ```
241
- * "C".hashCode // constant folded
241
+ * def hashCode: Int = "C".hashCode // constant folded
242
242
* ```
243
243
*
244
244
* The class
@@ -247,7 +247,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
247
247
* case class C(x: T, y: U)
248
248
* ```
249
249
*
250
- * if non of `T` or `U` are primitive types, gets the `hashCode` method:
250
+ * if none of `T` or `U` are primitive types, gets the `hashCode` method:
251
251
*
252
252
* ```
253
253
* def hashCode: Int = ScalaRunTime._hashCode(this)
@@ -256,12 +256,12 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
256
256
* else if either `T` or `U` are primitive, gets the `hashCode` method implemented by [[caseHashCodeBody ]]
257
257
*/
258
258
def chooseHashcode (implicit ctx : Context ) = {
259
- if clazz.is(ModuleClass ) then
259
+ if ( clazz.is(ModuleClass ))
260
260
Literal (Constant (clazz.name.stripModuleClassSuffix.toString.hashCode))
261
- else if accessors `exists` (_.info.finalResultType.classSymbol.isPrimitiveValueClass) then
261
+ else if ( accessors `exists` (_.info.finalResultType.classSymbol.isPrimitiveValueClass))
262
262
caseHashCodeBody
263
263
else
264
- ref(defn.ScalaRuntimeModule ).select(" _hashCode " .toTermName ).appliedTo(This (clazz))
264
+ ref(defn.ScalaRuntimeModule ).select(defn. ScalaRuntime__hashCode ).appliedTo(This (clazz))
265
265
}
266
266
267
267
/** The class
@@ -275,19 +275,19 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
275
275
* ```
276
276
* def hashCode: Int = {
277
277
* <synthetic> var acc: Int = 0xcafebabe
278
- * acc = Statics.mix(acc, this.productPrefix.hashCode);
278
+ * acc = Statics.mix(acc, this.productPrefix.hashCode() );
279
279
* acc = Statics.mix(acc, x);
280
280
* acc = Statics.mix(acc, Statics.this.anyHash(y));
281
281
* Statics.finalizeHash(acc, 2)
282
282
* }
283
283
* ```
284
284
*/
285
285
def caseHashCodeBody (implicit ctx : Context ): Tree = {
286
- val acc = ctx.newSymbol(ctx.owner, " acc " .toTermName , Mutable | Synthetic , defn.IntType , coord = ctx.owner.span)
287
- val accDef = ValDef (acc, Literal (Constant (0xcafebabe )))
286
+ val acc = ctx.newSymbol(ctx.owner, nme.acc , Mutable | Synthetic , defn.IntType , coord = ctx.owner.span)
287
+ val accDef = ValDef (acc, Literal (Constant (0xcafebabe )))
288
288
val mixPrefix = Assign (ref(acc),
289
- ref(defn.staticsMethod(" mix" )).appliedTo(ref(acc), This (clazz).select(defn.Product_productPrefix ).select(defn.Any_hashCode )))
290
- val mixes = for accessor <- accessors yield
289
+ ref(defn.staticsMethod(" mix" )).appliedTo(ref(acc), This (clazz).select(defn.Product_productPrefix ).select(defn.Any_hashCode ).appliedToNone ))
290
+ val mixes = for ( accessor <- accessors) yield
291
291
Assign (ref(acc), ref(defn.staticsMethod(" mix" )).appliedTo(ref(acc), hashImpl(accessor)))
292
292
val finish = ref(defn.staticsMethod(" finalizeHash" )).appliedTo(ref(acc), Literal (Constant (accessors.size)))
293
293
Block (accDef :: mixPrefix :: mixes, finish)
0 commit comments