Skip to content

Commit 0339598

Browse files
authored
Backport "Adjust owner in Interactive.contextOfPath causing crash in ImplicitSearch" to 3.4.1 (#19928)
Backports #19875
2 parents c31ddcd + 7aa17c5 commit 0339598

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Diff for: compiler/src/dotty/tools/dotc/interactive/Interactive.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,14 @@ object Interactive {
297297
else
298298
outer
299299
case tree @ Block(stats, expr) =>
300-
val localCtx = outer.fresh.setNewScope
300+
val localCtx = outer.localContext(tree, outer.owner).setNewScope
301301
stats.foreach {
302302
case stat: MemberDef => localCtx.enter(stat.symbol)
303303
case _ =>
304304
}
305-
contextOfStat(stats, nested, ctx.owner, localCtx)
305+
contextOfStat(stats, nested, localCtx.owner, localCtx)
306306
case tree @ CaseDef(pat, _, _) =>
307-
val localCtx = outer.fresh.setNewScope
307+
val localCtx = outer.localContext(tree, outer.owner).setNewScope
308308
pat.foreachSubTree {
309309
case bind: Bind => localCtx.enter(bind.symbol)
310310
case _ =>

Diff for: language-server/test/dotty/tools/languageserver/CompletionTest.scala

+14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ class CompletionTest {
3535
.completion(("Conversion", Class, "Conversion"))
3636
}
3737

38+
@Test def implicitSearchCrash: Unit =
39+
code"""
40+
|object Test:
41+
| trait Foo:
42+
| def test(): String
43+
| given Int = ???
44+
| given (using ev: Int): Conversion[String, Foo] = ???
45+
|
46+
| val test = {
47+
| "".tes$m1
48+
| 1
49+
| }"""
50+
.completion(("test", Method, "(): String"))
51+
3852
@Test def completionFromScalaPackageObject: Unit = {
3953
code"class Foo { val foo: BigD${m1} }"
4054
.completion(

0 commit comments

Comments
 (0)