Skip to content

Commit ebb4ba2

Browse files
committed
Avoid repeated tpd. prefixes in Implicits.scala
1 parent 50bf462 commit ebb4ba2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import reporting.trace
3838

3939
/** Implicit resolution */
4040
object Implicits {
41+
import tpd._
4142

4243
/** A reference to an implicit value to be made visible on the next nested call to
4344
* inferImplicitArg with a by-name expected type.
@@ -255,7 +256,7 @@ object Implicits {
255256

256257
/** The result of an implicit search */
257258
sealed abstract class SearchResult extends Showable {
258-
def tree: tpd.Tree
259+
def tree: Tree
259260
def toText(printer: Printer): Text = printer.toText(this)
260261
def recoverWith(other: SearchFailure => SearchResult) = this match {
261262
case _: SearchSuccess => this
@@ -269,10 +270,10 @@ object Implicits {
269270
* @param level The level where the reference was found
270271
* @param tstate The typer state to be committed if this alternative is chosen
271272
*/
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
273274

274275
/** A failed search */
275-
case class SearchFailure(tree: tpd.Tree) extends SearchResult {
276+
case class SearchFailure(tree: Tree) extends SearchResult {
276277
final def isAmbiguous = tree.tpe.isInstanceOf[AmbiguousImplicits]
277278
final def reason = tree.tpe.asInstanceOf[SearchFailureType]
278279
}
@@ -288,7 +289,7 @@ object Implicits {
288289

289290
abstract class SearchFailureType extends ErrorType {
290291
def expectedType: Type
291-
protected def argument: tpd.Tree
292+
protected def argument: Tree
292293

293294
final protected def qualify(implicit ctx: Context) =
294295
if (expectedType.exists)
@@ -309,18 +310,18 @@ object Implicits {
309310
def whyNoConversion(implicit ctx: Context): String = ""
310311
}
311312

312-
class NoMatchingImplicits(val expectedType: Type, val argument: tpd.Tree) extends SearchFailureType {
313+
class NoMatchingImplicits(val expectedType: Type, val argument: Tree) extends SearchFailureType {
313314
def explanation(implicit ctx: Context): String =
314315
em"no implicit values were found that $qualify"
315316
}
316317

317-
@sharable object NoMatchingImplicits extends NoMatchingImplicits(NoType, tpd.EmptyTree)
318+
@sharable object NoMatchingImplicits extends NoMatchingImplicits(NoType, EmptyTree)
318319

319320
@sharable val NoMatchingImplicitsFailure: SearchFailure =
320321
SearchFailure(NoMatchingImplicits)
321322

322323
/** 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 {
324325
def explanation(implicit ctx: Context): String =
325326
em"both ${err.refStr(alt1.ref)} and ${err.refStr(alt2.ref)} $qualify"
326327
override def whyNoConversion(implicit ctx: Context) =
@@ -330,22 +331,22 @@ object Implicits {
330331

331332
class MismatchedImplicit(ref: TermRef,
332333
val expectedType: Type,
333-
val argument: tpd.Tree) extends SearchFailureType {
334+
val argument: Tree) extends SearchFailureType {
334335
def explanation(implicit ctx: Context): String =
335336
em"${err.refStr(ref)} does not $qualify"
336337
}
337338

338339
class ShadowedImplicit(ref: TermRef,
339340
shadowing: Type,
340341
val expectedType: Type,
341-
val argument: tpd.Tree) extends SearchFailureType {
342+
val argument: Tree) extends SearchFailureType {
342343
def explanation(implicit ctx: Context): String =
343344
em"${err.refStr(ref)} does $qualify but is shadowed by ${err.refStr(shadowing)}"
344345
}
345346

346347
class DivergingImplicit(ref: TermRef,
347348
val expectedType: Type,
348-
val argument: tpd.Tree) extends SearchFailureType {
349+
val argument: Tree) extends SearchFailureType {
349350
def explanation(implicit ctx: Context): String =
350351
em"${err.refStr(ref)} produces a diverging implicit search when trying to $qualify"
351352
}
@@ -640,7 +641,7 @@ trait Implicits { self: Typer =>
640641
arg
641642
}
642643

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 = {
644645
def msg(shortForm: String)(headline: String = shortForm) = arg match {
645646
case arg: Trees.SearchFailureIdent[_] =>
646647
shortForm
@@ -913,7 +914,10 @@ trait Implicits { self: Typer =>
913914
false
914915
}
915916

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+
*/
917921
def sort(eligible: List[Candidate]) = eligible match {
918922
case Nil => eligible
919923
case e1 :: Nil => eligible

0 commit comments

Comments
 (0)