summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-02-10 08:59:22 +0100
committerJason Zaugg <jzaugg@gmail.com>2014-02-10 09:06:45 +0100
commitd6b1e6e4ff1cb477e9b26ba7e1a02d1ea98fa132 (patch)
treea1ca801457c9ac28e219752790475eaabffa9ea0
parent9f142b114be1261f55ea82b9cd1f9d9f91b3cad6 (diff)
downloadscala-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}`
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala8
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala7
-rw-r--r--test/files/neg/t6260-named.scala2
3 files changed, 13 insertions, 4 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)
diff --git a/test/files/neg/t6260-named.scala b/test/files/neg/t6260-named.scala
index 7ce13476eb..7cd9ce8473 100644
--- a/test/files/neg/t6260-named.scala
+++ b/test/files/neg/t6260-named.scala
@@ -7,7 +7,7 @@ object Test {
(x: C[Any]) => {println(s"f($x)"); x} // okay
new T[C[Any]] { def apply(a: C[Any]) = a } // okay
- // we can't rename the specific apply methid to avoid the clash
+ // we can't rename the specific apply method to avoid the clash
object O extends Function1[C[Any], C[Any]] {
def apply(a: C[Any]) = a
}