From f9879b63a87b1e3062c58abd9ce30e68d9fee8ca Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 20 Mar 2019 09:09:47 +1000 Subject: [PATCH] Remove backwards compatibility from extension methods Using new STARR 2.13.0-M5-5eef812 --- .../nsc/transform/ExtensionMethods.scala | 39 +------------------ versions.properties | 2 +- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index 9842ad96ac36..2220199dd853 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -36,39 +36,6 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { def newTransformer(unit: CompilationUnit): Transformer = new Extender(unit) - /** Generate stream of possible names for the extension version of given instance method `imeth`. - * If the method is not overloaded, this stream consists of just "extension$imeth". - * If the method is overloaded, the stream has as first element "extensionX$imeth", where X is the - * index of imeth in the sequence of overloaded alternatives with the same name. This choice will - * always be picked as the name of the generated extension method. - * After this first choice, all other possible indices in the range of 0 until the number - * of overloaded alternatives are returned. The secondary choices are used to find a matching method - * in `extensionMethod` if the first name has the wrong type. We thereby gain a level of insensitivity - * of how overloaded types are ordered between phases and picklings. - */ - // TODO 2.13.1 Remove the $N variants, just return the one and only name. - private def extensionNames(imeth: Symbol): Stream[Name] = { - val decl = imeth.owner.info.decl(imeth.name) - - // Bridge generation is done at phase `erasure`, but new scopes are only generated - // for the phase after that. So bridges are visible in earlier phases. - // - // `info.member(imeth.name)` filters these out, but we need to use `decl` - // to restrict ourselves to members defined in the current class, so we - // must do the filtering here. - val declTypeNoBridge = decl.filter(sym => !sym.isBridge).tpe - - declTypeNoBridge match { - case OverloadedType(_, alts) => - val index = alts indexOf imeth - assert(index >= 0, alts+" does not contain "+imeth) - def altName(index: Int) = extensionName(imeth.name).append(index.toString) - extensionName(imeth.name) #:: ((0 until alts.length).toStream map altName) - case tpe => - assert(tpe != NoType, imeth.name+" not found in "+imeth.owner+"'s decls: "+imeth.owner.info.decls) - Stream(extensionName(imeth.name)) - } - } private def extensionName(name: Name): TermName = { name.append("$extension").toTermName } @@ -81,7 +48,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { /** Return the extension method that corresponds to given instance method `meth`. */ def extensionMethod(imeth: Symbol): Symbol = enteringPhase(currentRun.refchecksPhase) { val companionInfo = companionModuleForce(imeth.owner).info - val candidates = extensionNames(imeth).map(companionInfo.decl(_)).filter(_.exists).flatMap(_.alternatives) + val candidates = companionInfo.decl(extensionName(imeth.name)).alternatives val matching = candidates filter (alt => normalize(alt.tpe, imeth.owner) matches imeth.tpe) assert(matching.nonEmpty, sm"""|no extension method found for: @@ -94,9 +61,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { | | Candidates (signatures normalized): | - | ${candidates.map(c => c.name+":"+normalize(c.tpe, imeth.owner)).mkString("\n")} - | - | Eligible Names: ${extensionNames(imeth).mkString(",")}" """) + | ${candidates.map(c => c.name+":"+normalize(c.tpe, imeth.owner)).mkString("\n")}" """) matching.head } diff --git a/versions.properties b/versions.properties index debbe532f80d..074c6ea3d228 100644 --- a/versions.properties +++ b/versions.properties @@ -1,5 +1,5 @@ # Scala version used for bootstrapping (see README.md) -starr.version=2.13.0-M5-1775dba +starr.version=2.13.0-M5-5eef812 # These are the versions of the modules that go with this release. # Artifact dependencies: