Skip to content

Commit

Permalink
Backport "Adjust owner in Interactive.contextOfPath causing crash i…
Browse files Browse the repository at this point in the history
…n `ImplicitSearch`" to LTS (#20977)

Backports #19875 to the LTS branch.

PR submitted by the release tooling.
  • Loading branch information
WojciechMazur authored Jul 3, 2024
2 parents 81d1df0 + e7653ee commit 26fb24a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/interactive/Interactive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ object Interactive {
else
outer
case tree @ Block(stats, expr) =>
val localCtx = outer.fresh.setNewScope
val localCtx = outer.localContext(tree, outer.owner).setNewScope
stats.foreach {
case stat: MemberDef => localCtx.enter(stat.symbol)
case _ =>
}
contextOfStat(stats, nested, ctx.owner, localCtx)
contextOfStat(stats, nested, localCtx.owner, localCtx)
case tree @ CaseDef(pat, _, _) =>
val localCtx = outer.fresh.setNewScope
val localCtx = outer.localContext(tree, outer.owner).setNewScope
pat.foreachSubTree {
case bind: Bind => localCtx.enter(bind.symbol)
case _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ class CompletionTest {
.completion(("Conversion", Class, "Conversion"))
}

@Test def implicitSearchCrash: Unit =
code"""
|object Test:
| trait Foo:
| def test(): String
| given Int = ???
| given (using ev: Int): Conversion[String, Foo] = ???
|
| val test = {
| "".tes$m1
| 1
| }"""
.completion(("test", Method, "(): String"))

@Test def completionFromScalaPackageObject: Unit = {
code"class Foo { val foo: BigD${m1} }"
.completion(
Expand Down

0 comments on commit 26fb24a

Please sign in to comment.