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

Suggestion crashes with a Conversion requiring a using parameter #6193

Closed
ChenCMD opened this issue Mar 3, 2024 · 2 comments · Fixed by scala/scala3#19875
Closed

Suggestion crashes with a Conversion requiring a using parameter #6193

ChenCMD opened this issue Mar 3, 2024 · 2 comments · Fixed by scala/scala3#19875
Assignees
Labels
bug Something that is making a piece of functionality unusable presentation-compiler Something relating to the presentation compiler Scala 3 Generic ticket relating to Scala 3
Milestone

Comments

@ChenCMD
Copy link

ChenCMD commented Mar 3, 2024

Describe the bug

When I input a . after "" on line 5 in the minimized code, metals does not show any suggestion and instead reports a compiler error.

Minimized code

given Int = ???
given (using ev: Int): Conversion[String, Any] = ???

val test = {
  ""./* Trigger Suggest here */
  1
}

Error report

file:///C:/Users/scnme/Chen_Data/Programming/Scala/Test/src/main/scala/Main.scala
### java.lang.AssertionError: NoDenotation.owner

occurred in the presentation compiler.

action parameters:
offset: 88
uri: file:///C:/Users/scnme/Chen_Data/Programming/Scala/Test/src/main/scala/Main.scala
text:
```scala
given Int = ???
given (using ev: Int): Conversion[String, Any] = ???

val test = {
  "".@@
  ???
}

```



#### Error stacktrace:

```
dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2603)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.candSucceedsGiven$1(Implicits.scala:1586)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.comesTooLate$1(Implicits.scala:1595)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.$anonfun$5(Implicits.scala:1600)
	scala.collection.immutable.List.filterNot(List.scala:515)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1600)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1686)
	dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:1093)
	dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:851)
	dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:120)
	dotty.tools.dotc.typer.Implicits.inferImplicitArg(Implicits.scala:917)
	dotty.tools.dotc.typer.Implicits.inferImplicitArg$(Implicits.scala:851)
	dotty.tools.dotc.typer.Typer.inferImplicitArg(Typer.scala:120)
	dotty.tools.dotc.typer.Typer.implicitArgs$1(Typer.scala:3817)
	dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:3853)
	dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:3932)
	dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4132)
	dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4368)
	dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3679)
	dotty.tools.dotc.typer.Implicits.tryConversion$1(Implicits.scala:1164)
	dotty.tools.dotc.typer.Implicits.typedImplicit(Implicits.scala:1200)
	dotty.tools.dotc.typer.Implicits.typedImplicit$(Implicits.scala:851)
	dotty.tools.dotc.typer.Typer.typedImplicit(Typer.scala:120)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.tryImplicit(Implicits.scala:1275)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.$anonfun$6(Implicits.scala:1694)
	scala.collection.immutable.List.map(List.scala:246)
	dotty.tools.dotc.typer.Implicits$ImplicitSearch.allImplicits(Implicits.scala:1694)
	dotty.tools.dotc.interactive.Completion$Completer.implicitConversionTargets(Completion.scala:556)
	dotty.tools.dotc.interactive.Completion$Completer.implicitConversionMemberCompletions(Completion.scala:421)
	dotty.tools.dotc.interactive.Completion$Completer.selectionCompletions(Completion.scala:363)
	dotty.tools.dotc.interactive.Completion$.computeCompletions(Completion.scala:188)
	dotty.tools.dotc.interactive.Completion$.completions(Completion.scala:53)
	dotty.tools.pc.completions.Completions.completions(Completions.scala:128)
	dotty.tools.pc.completions.CompletionProvider.completions(CompletionProvider.scala:87)
	dotty.tools.pc.ScalaPresentationCompiler.complete$$anonfun$1(ScalaPresentationCompiler.scala:143)
```
#### Short summary: 

java.lang.AssertionError: NoDenotation.owner

Expected behavior

Suggestions (for a String value) should be listed.

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

v1.2.2

Extra context or search terms

No response

@jkciesluk
Copy link
Member

Thanks for reporting!
Which Scala version are you using?

@jkciesluk jkciesluk self-assigned this Mar 4, 2024
@jkciesluk jkciesluk added bug Something that is making a piece of functionality unusable Scala 3 Generic ticket relating to Scala 3 presentation-compiler Something relating to the presentation compiler labels Mar 4, 2024
@jkciesluk jkciesluk assigned rochala and unassigned jkciesluk Mar 4, 2024
@ChenCMD
Copy link
Author

ChenCMD commented Mar 4, 2024

Tried Scala 3.4.0 and 3.4.1-RC1.

rochala added a commit to scala/scala3 that referenced this issue Mar 5, 2024
…tSearch` (#19875)

`Interactive` provided us with the method `contextOfPath` which should
return enclosing ctx for given position. It was working fine until given
loop detection was improved some time ago.

It started crashing as the context owner was set to original context
owner, instead of the real owner. This PR changes this and sets context
to its outer context owner.

Fixes scalameta/metals#6193
Kordyjan pushed a commit to dotty-staging/dotty that referenced this issue Mar 12, 2024
…tSearch` (scala#19875)

`Interactive` provided us with the method `contextOfPath` which should
return enclosing ctx for given position. It was working fine until given
loop detection was improved some time ago.

It started crashing as the context owner was set to original context
owner, instead of the real owner. This PR changes this and sets context
to its outer context owner.

Fixes scalameta/metals#6193
@tgodzik tgodzik added this to the Metals v1.3.0 milestone Apr 11, 2024
WojciechMazur pushed a commit to scala/scala3 that referenced this issue Jul 2, 2024
…tSearch` (#19875)

`Interactive` provided us with the method `contextOfPath` which should
return enclosing ctx for given position. It was working fine until given
loop detection was improved some time ago.

It started crashing as the context owner was set to original context
owner, instead of the real owner. This PR changes this and sets context
to its outer context owner.

Fixes scalameta/metals#6193
[Cherry-picked 9cc9107]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable presentation-compiler Something relating to the presentation compiler Scala 3 Generic ticket relating to Scala 3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants