@@ -71,17 +71,20 @@ object Implicits {
7171 /** The implicit references */
7272 def refs : List [ImplicitRef ]
7373
74+ private var SingletonClass : ClassSymbol = null
75+
76+ /** Widen type so that it is neither a singleton type nor it inherits from scala.Singleton. */
77+ private def widenSingleton (tp : Type )(implicit ctx : Context ): Type = {
78+ if (SingletonClass == null ) SingletonClass = defn.SingletonClass
79+ val wtp = tp.widenSingleton
80+ if (wtp.derivesFrom(SingletonClass )) defn.AnyType else wtp
81+ }
82+
7483 /** Return those references in `refs` that are compatible with type `pt`. */
7584 protected def filterMatching (pt : Type )(implicit ctx : Context ): List [Candidate ] = track(" filterMatching" ) {
7685
7786 def refMatches (ref : TermRef )(implicit ctx : Context ) = /* trace(i"refMatches $ref $pt")*/ {
7887
79- /** Widen type so that it is neither a singleton type nor it inherits from scala.Singleton. */
80- def widenSingleton (tp : Type ): Type = {
81- val wtp = tp.widenSingleton
82- if (wtp.derivesFrom(defn.SingletonClass )) defn.AnyType else wtp
83- }
84-
8588 def discardForView (tpw : Type , argType : Type ): Boolean = tpw match {
8689 case mt : MethodType =>
8790 mt.isImplicitMethod ||
@@ -150,7 +153,7 @@ object Implicits {
150153 val res = adjustSingletonArg(tp.resType)
151154 if (res `eq` tp.resType) tp else tp.derivedLambdaType(resType = res)
152155 case tp : MethodType =>
153- tp.derivedLambdaType(paramInfos = tp.paramInfos.map (widenSingleton))
156+ tp.derivedLambdaType(paramInfos = tp.paramInfos.mapConserve (widenSingleton))
154157 case _ => tp
155158 }
156159
0 commit comments