Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Adjust owner in Interactive.contextOfPath causing crash in ImplicitSearch" to LTS #20977

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading