Skip to content

Commit 9fc6a14

Browse files
authored
Merge pull request #12783 from dos65/interactive_context_of_path_fix
2 parents b034157 + 0296150 commit 9fc6a14

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,10 @@ object Interactive {
293293
// in subsequent parameter sections
294294
localCtx
295295
case tree: MemberDef =>
296-
assert(tree.symbol.exists)
297-
outer.localContext(tree, tree.symbol)
296+
if (tree.symbol.exists)
297+
outer.localContext(tree, tree.symbol)
298+
else
299+
outer
298300
case tree @ Block(stats, expr) =>
299301
val localCtx = outer.fresh.setNewScope
300302
stats.foreach {
@@ -310,7 +312,7 @@ object Interactive {
310312
}
311313
localCtx
312314
case tree @ Template(constr, parents, self, _) =>
313-
if ((constr :: self :: parents).contains(nested)) ctx
315+
if ((constr :: self :: parents).contains(nested)) outer
314316
else contextOfStat(tree.body, nested, tree.symbol, outer.inClassContext(self.symbol))
315317
case _ =>
316318
outer

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,4 +994,33 @@ class CompletionTest {
994994
("annotation", Module, "scala.annotation")
995995
)
996996
)
997+
@Test def completeTemplateConstrArgType: Unit = {
998+
val expected = Set(
999+
("Future", Class, "scala.concurrent.Future"),
1000+
("Future", Module, "scala.concurrent.Future")
1001+
)
1002+
code"""import scala.concurrent.Future
1003+
|class Foo(x: Fut${m1})""".withSource
1004+
.completion(m1, expected)
1005+
}
1006+
1007+
@Test def completeTemplateParents: Unit = {
1008+
val expected = Set(
1009+
("Future", Class, "scala.concurrent.Future"),
1010+
("Future", Module, "scala.concurrent.Future")
1011+
)
1012+
code"""import scala.concurrent.Future
1013+
|class Foo extends Futu${m1}""".withSource
1014+
.completion(m1, expected)
1015+
}
1016+
1017+
@Test def completeTemplateSelfType: Unit = {
1018+
val expected = Set(
1019+
("Future", Class, "scala.concurrent.Future"),
1020+
("Future", Module, "scala.concurrent.Future")
1021+
)
1022+
code"""import scala.concurrent.Future
1023+
|class Foo[A]{ self: Futu${m1} => }""".withSource
1024+
.completion(m1, expected)
1025+
}
9971026
}

0 commit comments

Comments
 (0)