File tree Expand file tree Collapse file tree 4 files changed +8
-4
lines changed
reflect/scala/reflect/internal Expand file tree Collapse file tree 4 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ abstract class Pickler extends SubComponent {
8080 private var entries = new Array [AnyRef ](256 )
8181 private var ep = 0
8282 private val index = new LinkedHashMap [AnyRef , Int ]
83- private lazy val nonClassRoot = findOrElse (root.ownersIterator)(! _.isClass)( NoSymbol )
83+ private lazy val nonClassRoot = findSymbol (root.ownersIterator)(! _.isClass)
8484
8585 private def isRootSym (sym : Symbol ) =
8686 sym.name.toTermName == rootName && sym.owner == rootOwner
Original file line number Diff line number Diff line change @@ -3418,7 +3418,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
34183418 val nvPairs = args map {
34193419 case arg @ AssignOrNamedArg (Ident (name), rhs) =>
34203420 val sym = if (isJava) annScope.lookup(name)
3421- else typedFun.tpe.params.find(p => p .name == name).getOrElse( NoSymbol )
3421+ else findSymbol( typedFun.tpe.params)(_ .name == name)
34223422 if (sym == NoSymbol ) {
34233423 reportAnnotationError(UnknownAnnotationNameError (arg, name))
34243424 (nme.ERROR , None )
Original file line number Diff line number Diff line change @@ -221,8 +221,8 @@ trait Scopes extends api.Scopes { self: SymbolTable =>
221221 /** Lookup a module or a class, filtering out matching names in scope
222222 * which do not match that requirement.
223223 */
224- def lookupModule (name : Name ): Symbol = lookupAll(name.toTermName) find (_.isModule) getOrElse NoSymbol
225- def lookupClass (name : Name ): Symbol = lookupAll(name.toTypeName) find (_.isClass) getOrElse NoSymbol
224+ def lookupModule (name : Name ): Symbol = findSymbol( lookupAll(name.toTermName)) (_.isModule)
225+ def lookupClass (name : Name ): Symbol = findSymbol( lookupAll(name.toTypeName)) (_.isClass)
226226
227227 /** True if the name exists in this scope, false otherwise. */
228228 def containsName (name : Name ) = lookupEntry(name) != null
Original file line number Diff line number Diff line change @@ -124,6 +124,10 @@ abstract class SymbolTable extends macros.Universe
124124 result
125125 }
126126
127+ @ inline final def findSymbol (xs : TraversableOnce [Symbol ])(p : Symbol => Boolean ): Symbol = {
128+ xs find p getOrElse NoSymbol
129+ }
130+
127131 // For too long have we suffered in order to sort NAMES.
128132 // I'm pretty sure there's a reasonable default for that.
129133 // Notice challenge created by Ordering's invariance.
You can’t perform that action at this time.
0 commit comments