@@ -38,6 +38,7 @@ import reporting.trace
38
38
39
39
/** Implicit resolution */
40
40
object Implicits {
41
+ import tpd ._
41
42
42
43
/** A reference to an implicit value to be made visible on the next nested call to
43
44
* inferImplicitArg with a by-name expected type.
@@ -255,7 +256,7 @@ object Implicits {
255
256
256
257
/** The result of an implicit search */
257
258
sealed abstract class SearchResult extends Showable {
258
- def tree : tpd. Tree
259
+ def tree : Tree
259
260
def toText (printer : Printer ): Text = printer.toText(this )
260
261
def recoverWith (other : SearchFailure => SearchResult ) = this match {
261
262
case _ : SearchSuccess => this
@@ -269,10 +270,10 @@ object Implicits {
269
270
* @param level The level where the reference was found
270
271
* @param tstate The typer state to be committed if this alternative is chosen
271
272
*/
272
- case class SearchSuccess (tree : tpd. Tree , ref : TermRef , level : Int )(val tstate : TyperState ) extends SearchResult with Showable
273
+ case class SearchSuccess (tree : Tree , ref : TermRef , level : Int )(val tstate : TyperState ) extends SearchResult with Showable
273
274
274
275
/** A failed search */
275
- case class SearchFailure (tree : tpd. Tree ) extends SearchResult {
276
+ case class SearchFailure (tree : Tree ) extends SearchResult {
276
277
final def isAmbiguous = tree.tpe.isInstanceOf [AmbiguousImplicits ]
277
278
final def reason = tree.tpe.asInstanceOf [SearchFailureType ]
278
279
}
@@ -288,7 +289,7 @@ object Implicits {
288
289
289
290
abstract class SearchFailureType extends ErrorType {
290
291
def expectedType : Type
291
- protected def argument : tpd. Tree
292
+ protected def argument : Tree
292
293
293
294
final protected def qualify (implicit ctx : Context ) =
294
295
if (expectedType.exists)
@@ -309,18 +310,18 @@ object Implicits {
309
310
def whyNoConversion (implicit ctx : Context ): String = " "
310
311
}
311
312
312
- class NoMatchingImplicits (val expectedType : Type , val argument : tpd. Tree ) extends SearchFailureType {
313
+ class NoMatchingImplicits (val expectedType : Type , val argument : Tree ) extends SearchFailureType {
313
314
def explanation (implicit ctx : Context ): String =
314
315
em " no implicit values were found that $qualify"
315
316
}
316
317
317
- @ sharable object NoMatchingImplicits extends NoMatchingImplicits (NoType , tpd. EmptyTree )
318
+ @ sharable object NoMatchingImplicits extends NoMatchingImplicits (NoType , EmptyTree )
318
319
319
320
@ sharable val NoMatchingImplicitsFailure : SearchFailure =
320
321
SearchFailure (NoMatchingImplicits )
321
322
322
323
/** An ambiguous implicits failure */
323
- class AmbiguousImplicits (val alt1 : SearchSuccess , val alt2 : SearchSuccess , val expectedType : Type , val argument : tpd. Tree ) extends SearchFailureType {
324
+ class AmbiguousImplicits (val alt1 : SearchSuccess , val alt2 : SearchSuccess , val expectedType : Type , val argument : Tree ) extends SearchFailureType {
324
325
def explanation (implicit ctx : Context ): String =
325
326
em " both ${err.refStr(alt1.ref)} and ${err.refStr(alt2.ref)} $qualify"
326
327
override def whyNoConversion (implicit ctx : Context ) =
@@ -330,22 +331,22 @@ object Implicits {
330
331
331
332
class MismatchedImplicit (ref : TermRef ,
332
333
val expectedType : Type ,
333
- val argument : tpd. Tree ) extends SearchFailureType {
334
+ val argument : Tree ) extends SearchFailureType {
334
335
def explanation (implicit ctx : Context ): String =
335
336
em " ${err.refStr(ref)} does not $qualify"
336
337
}
337
338
338
339
class ShadowedImplicit (ref : TermRef ,
339
340
shadowing : Type ,
340
341
val expectedType : Type ,
341
- val argument : tpd. Tree ) extends SearchFailureType {
342
+ val argument : Tree ) extends SearchFailureType {
342
343
def explanation (implicit ctx : Context ): String =
343
344
em " ${err.refStr(ref)} does $qualify but is shadowed by ${err.refStr(shadowing)}"
344
345
}
345
346
346
347
class DivergingImplicit (ref : TermRef ,
347
348
val expectedType : Type ,
348
- val argument : tpd. Tree ) extends SearchFailureType {
349
+ val argument : Tree ) extends SearchFailureType {
349
350
def explanation (implicit ctx : Context ): String =
350
351
em " ${err.refStr(ref)} produces a diverging implicit search when trying to $qualify"
351
352
}
@@ -640,7 +641,7 @@ trait Implicits { self: Typer =>
640
641
arg
641
642
}
642
643
643
- def missingArgMsg (arg : tpd. Tree , pt : Type , where : String )(implicit ctx : Context ): String = {
644
+ def missingArgMsg (arg : Tree , pt : Type , where : String )(implicit ctx : Context ): String = {
644
645
def msg (shortForm : String )(headline : String = shortForm) = arg match {
645
646
case arg : Trees .SearchFailureIdent [_] =>
646
647
shortForm
@@ -913,7 +914,10 @@ trait Implicits { self: Typer =>
913
914
false
914
915
}
915
916
916
- /** Sort list of implicit references according to `prefer` */
917
+ /** Sort list of implicit references according to `prefer`.
918
+ * This is just an optimization that aims at reducing the average
919
+ * number of candidates to be tested.
920
+ */
917
921
def sort (eligible : List [Candidate ]) = eligible match {
918
922
case Nil => eligible
919
923
case e1 :: Nil => eligible
0 commit comments