Skip to content

Commit 33f332a

Browse files
committed
Small refactor
1 parent c2849d4 commit 33f332a

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ object Completion:
526526
// There are four possible ways for an extension method to be applicable
527527

528528
// 1. The extension method is visible under a simple name, by being defined or inherited or imported in a scope enclosing the reference.
529-
val termCompleter = new Completer(Mode.Term, prefix, pos, _.startsWith(prefix))
529+
val termCompleter = new Completer(Mode.Term, prefix, pos, prefixFilter)
530530
val extMethodsInScope = termCompleter.scopeCompletions.toList.flatMap {
531531
case (name, denots) => denots.collect { case d: SymDenotation if d.isTerm => (d.termRef, name.asTermName) }
532532
}
@@ -609,7 +609,6 @@ object Completion:
609609
private def implicitConversionTargets(qual: tpd.Tree)(using Context): Set[SearchSuccess] = {
610610
val typer = ctx.typer
611611
val conversions = new typer.ImplicitSearch(defn.AnyType, qual, pos.span).allImplicits
612-
conversions.map(_.tree.typeOpt)
613612

614613
interactiv.println(i"implicit conversion targets considered: ${conversions.toList}%, %")
615614
conversions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ object Implicits:
531531
|must be more specific than $target""" :: Nil
532532

533533
override def msg(using Context) =
534-
super.msg.append("\nThe expected type $target is not specific enough, so no search was attempted")
534+
super.msg.append(i"\nThe expected type $target is not specific enough, so no search was attempted")
535535

536536
override def toString = s"TooUnspecific"
537537
end TooUnspecific

presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Completions(
102102
end if
103103
end includeSymbol
104104

105-
val fuzzyMatcher: Name => Boolean = name =>
105+
lazy val fuzzyMatcher: Name => Boolean = name =>
106106
if completionMode.is(Mode.Member) then CompletionFuzzy.matchesSubCharacters(completionPos.query, name.toString)
107107
else CompletionFuzzy.matches(completionPos.query, name.toString)
108108

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ class CompletionSuite extends BaseCompletionSuite:
533533
|until(end: Long): Exclusive[Long]
534534
|until(end: Long, step: Long): Exclusive[Long]
535535
|""".stripMargin,
536-
postProcessObtained = _.replace("Float", "Double"),
537536
stableOrder = false
538537
)
539538

@@ -1818,3 +1817,24 @@ class CompletionSuite extends BaseCompletionSuite:
18181817
|""".stripMargin,
18191818
topLines = Some(1)
18201819
)
1820+
1821+
@Test def `fuzzy-search-test-multiple` =
1822+
check(
1823+
"""|
1824+
|trait MyInterface {
1825+
| def someMethod(x: Int): Int = ???
1826+
|}
1827+
|object Test {
1828+
| extension (interface: MyInterface) def someExtMethod(x: Int): Int = ???
1829+
| implicit class MyInterfaceExtension(interface: MyInterface):
1830+
| def someOldExtMethod(x: Int): Int = ???
1831+
| val x: MyInterface = ???
1832+
| x.m@@
1833+
|}
1834+
|""".stripMargin,
1835+
"""|someMethod(x: Int): Int
1836+
|someExtMethod(x: Int): Int
1837+
|someOldExtMethod(x: Int): Int
1838+
|""".stripMargin,
1839+
topLines = Some(3)
1840+
)

0 commit comments

Comments
 (0)