diff options
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r-- | src/compiler/scala/tools/nsc/Settings.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index f6221ac14b..95c3a56767 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -837,6 +837,7 @@ trait ScalacSettings { val Ypmatdebug = BooleanSetting ("-Ypmat-debug", "Trace all pattern matcher activity.") val Ytailrec = BooleanSetting ("-Ytailrecommend", "Alert methods which would be tail-recursive if private or final.") val YhigherKindedRaw = BooleanSetting ("-Yhigher-kinded-raw", "(temporary!) Treat raw Java types as higher-kinded types.") + val Yjenkins = BooleanSetting ("-Yjenkins-hashCodes", "Use jenkins hash algorithm for case class generated hashCodes.") // Equality specific val logEqEq = BooleanSetting ("-Ylog-eqeq", "Log all noteworthy equality tests") . diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index e3d75752f2..a3f628ebb4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -109,8 +109,8 @@ trait SyntheticMethods extends ast.TreeDSL { typer typed { DEF(method) === LIT(clazz.name.decode) } } - def forwardingMethod(name: Name): Tree = { - val target = getMember(ScalaRunTimeModule, "_" + name) + def forwardingMethod(name: Name, targetName: Name): Tree = { + val target = getMember(ScalaRunTimeModule, targetName) val paramtypes = target.tpe.paramTypes drop 1 val method = syntheticMethod( name, 0, makeTypeConstructor(paramtypes, target.tpe.resultType) @@ -123,6 +123,9 @@ trait SyntheticMethods extends ast.TreeDSL { } } + def hashCodeTarget: Name = + if (settings.Yjenkins.value) "hashCodeJenkins" else nme.hashCode_ + def equalsSym = syntheticMethod( nme.equals_, 0, makeTypeConstructor(List(AnyClass.tpe), BooleanClass.tpe) ) @@ -244,8 +247,8 @@ trait SyntheticMethods extends ast.TreeDSL { // methods for case classes only def classMethods = List( - Object_hashCode -> (() => forwardingMethod(nme.hashCode_)), - Object_toString -> (() => forwardingMethod(nme.toString_)), + Object_hashCode -> (() => forwardingMethod(nme.hashCode_, "_" + hashCodeTarget)), + Object_toString -> (() => forwardingMethod(nme.toString_, "_" + nme.toString_)), Object_equals -> (() => equalsClassMethod) ) // methods for case objects only |