diff options
author | Martin Odersky <odersky@gmail.com> | 2012-09-29 19:58:18 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-10-02 17:21:21 +0200 |
commit | d46f2d519de0f155d37a43927fb3924d2f2fbdb2 (patch) | |
tree | 67f776cb827f89bd389544774df8cccef033ecfc /src/compiler | |
parent | e9edc69684b3d55a0aef16325e358036c71f4c57 (diff) | |
download | scala-d46f2d519de0f155d37a43927fb3924d2f2fbdb2.tar.gz scala-d46f2d519de0f155d37a43927fb3924d2f2fbdb2.tar.bz2 scala-d46f2d519de0f155d37a43927fb3924d2f2fbdb2.zip |
SI-6215 Fix compiler crash on private method in value class
Fixes the problem with private defs in value classes by moving the $extension after the name proper rather than before. The previous scheme did not commute with makeNonPrivate:
I.e. if -ext-> is "generate extension name" and -mnp-> is "make not private" we did get for
method foo in value class Foo:
foo -ext-> extension$foo -mnp-> Foo$$extension$foo
but
foo -mnp-> Foo$$foo -ext-> extension$Foo$$foo
With the change both variations give the same name:
foo -ext-> foo$extension -mnp-> Foo$$foo$extension
but
foo -mnp-> Foo$$foo -ext-> Foo$$foo$extension
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index 8a9d0e58ec..6dd937c0ad 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -56,11 +56,11 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { case OverloadedType(_, alts) => val index = alts indexOf imeth assert(index >= 0, alts+" does not contain "+imeth) - def altName(index: Int) = newTermName("extension"+index+"$"+imeth.name) + def altName(index: Int) = newTermName(imeth.name+"$extension"+index) altName(index) #:: ((0 until alts.length).toStream filter (index != _) map altName) case tpe => assert(tpe != NoType, imeth.name+" not found in "+imeth.owner+"'s decls: "+imeth.owner.info.decls) - Stream(newTermName("extension$"+imeth.name)) + Stream(newTermName(imeth.name+"$extension")) } } @@ -68,10 +68,10 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { */ def extensionMethod(imeth: Symbol): Symbol = atPhase(currentRun.refchecksPhase) { val companionInfo = imeth.owner.companionModule.info - val candidates = extensionNames(imeth) map (companionInfo.decl(_)) + val candidates = extensionNames(imeth) map (companionInfo.decl(_)) filter (_.exists) val matching = candidates filter (alt => normalize(alt.tpe, imeth.owner) matches imeth.tpe) assert(matching.nonEmpty, - s"no extension method found for $imeth:${imeth.tpe}+among ${candidates map (c => c.name+":"+c.tpe)} / ${extensionNames(imeth)}") + s"no extension method found for $imeth:${imeth.tpe} among ${candidates map (c => c.name+":"+c.tpe)} / ${extensionNames(imeth)}") matching.head } |