diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-02-10 08:59:22 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-02-10 09:06:45 +0100 |
commit | d6b1e6e4ff1cb477e9b26ba7e1a02d1ea98fa132 (patch) | |
tree | a1ca801457c9ac28e219752790475eaabffa9ea0 /src | |
parent | 9f142b114be1261f55ea82b9cd1f9d9f91b3cad6 (diff) | |
download | scala-d6b1e6e4ff1cb477e9b26ba7e1a02d1ea98fa132.tar.gz scala-d6b1e6e4ff1cb477e9b26ba7e1a02d1ea98fa132.tar.bz2 scala-d6b1e6e4ff1cb477e9b26ba7e1a02d1ea98fa132.zip |
SI-6260 Adddress pull request review
- fix typo
- remove BRIDGE flag from the method that we promote from
a bridge to a bona-fide method
- note possibility for delambdafy to avoid the bridge method
creation in *all* cases.
- note inconsistency with anonymous class naming between
`-Ydelamdafy:{inline,method}`
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Delambdafy.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 7 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala index b28a4a507d..d81a5d5755 100644 --- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala +++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala @@ -232,6 +232,10 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre val parents = addSerializable(abstractFunctionErasedType) val funOwner = originalFunction.symbol.owner + // TODO harmonize the naming of delamdafy anon-fun classes with those spun up by Uncurry + // - make `anonClass.isAnonymousClass` true. + // - use `newAnonymousClassSymbol` or push the required variations into a similar factory method + // - reinstate the assertion in `Erasure.resolveAnonymousBridgeClash` val suffix = "$lambda$" + ( if (funOwner.isPrimaryConstructor) "" else "$" + funOwner.name @@ -283,8 +287,10 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre else s"$sym: ${sym.tpe} in ${sym.owner}" bridgeMethod foreach (bm => + // TODO SI-6260 maybe just create the apply method with the signature (Object => Object) in all cases + // rather than the method+bridge pair. if (bm.symbol.tpe =:= applyMethodDef.symbol.tpe) - erasure.expandNameOfMethodThatClashesBridge(applyMethodDef.symbol) + erasure.resolveAnonymousBridgeClash(applyMethodDef.symbol, bm.symbol) ) val body = members ++ List(constr, applyMethodDef) ++ bridgeMethod diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index e2ffafb850..60c1553ef3 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -484,7 +484,7 @@ abstract class Erasure extends AddInterfaces !sigContainsValueClass || (checkBridgeOverrides(member, other, bridge) match { case Nil => true - case es if member.owner.isAnonymousClass => expandNameOfMethodThatClashesBridge(member); true + case es if member.owner.isAnonymousClass => resolveAnonymousBridgeClash(member, bridge); true case es => for ((pos, msg) <- es) unit.error(pos, msg); false }) ) @@ -1137,9 +1137,12 @@ abstract class Erasure extends AddInterfaces } } - final def expandNameOfMethodThatClashesBridge(sym: Symbol) { + final def resolveAnonymousBridgeClash(sym: Symbol, bridge: Symbol) { + // TODO reinstate this after Delambdafy generates anonymous classes that meet this requirement. + // require(sym.owner.isAnonymousClass, sym.owner) log(s"Expanding name of ${sym.debugLocationString} as it clashes with bridge. Renaming deemed safe because the owner is anonymous.") sym.expandName(sym.owner) + bridge.resetFlag(BRIDGE) } private class TypeRefAttachment(val tpe: TypeRef) |