File tree 2 files changed +45
-1
lines changed
compiler/src/dotty/tools/dotc/interactive
presentation-compiler/test/dotty/tools/pc/tests/completion
2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,12 @@ object Completion:
186
186
)(using Context ): List [tpd.Tree ] =
187
187
untpdPath.collectFirst:
188
188
case untpd.ExtMethods (paramss, _) =>
189
- val enclosingParam = paramss.flatten.find(_.span.contains(pos.span))
189
+ val enclosingParam = paramss.flatten
190
+ .find(_.span.contains(pos.span))
191
+ .flatMap:
192
+ case untpd.TypeDef (_, bounds : untpd.ContextBounds ) => bounds.cxBounds.find(_.span.contains(pos.span))
193
+ case other => Some (other)
194
+
190
195
enclosingParam.map: param =>
191
196
ctx.typer.index(paramss.flatten)
192
197
val typedEnclosingParam = ctx.typer.typed(param)
Original file line number Diff line number Diff line change @@ -1838,3 +1838,42 @@ class CompletionSuite extends BaseCompletionSuite:
1838
1838
|""" .stripMargin,
1839
1839
topLines = Some (3 )
1840
1840
)
1841
+
1842
+ @ Test def `context-bound-in-extension-construct` =
1843
+ check(
1844
+ """
1845
+ |object x {
1846
+ | extension [T: Orde@@]
1847
+ |}
1848
+ |""" .stripMargin,
1849
+ """ Ordered[T] scala.math
1850
+ |Ordering[T] scala.math
1851
+ |""" .stripMargin,
1852
+ topLines = Some (2 )
1853
+ )
1854
+
1855
+ @ Test def `context-bounds-in-extension-construct` =
1856
+ check(
1857
+ """
1858
+ |object x {
1859
+ | extension [T: Ordering: Orde@@]
1860
+ |}
1861
+ |""" .stripMargin,
1862
+ """ Ordered[T] scala.math
1863
+ |Ordering[T] scala.math
1864
+ |""" .stripMargin,
1865
+ topLines = Some (2 )
1866
+ )
1867
+
1868
+ @ Test def `type-bound-in-extension-construct` =
1869
+ check(
1870
+ """
1871
+ |object x {
1872
+ | extension [T <: Orde@@]
1873
+ |}
1874
+ |""" .stripMargin,
1875
+ """ Ordered[T] scala.math
1876
+ |Ordering[T] scala.math
1877
+ |""" .stripMargin,
1878
+ topLines = Some (2 )
1879
+ )
You can’t perform that action at this time.
0 commit comments