Skip to content

Completions causing AssertionError with missing implicit parameter #13467

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

Closed
tgodzik opened this issue Sep 3, 2021 · 6 comments · Fixed by #13530
Closed

Completions causing AssertionError with missing implicit parameter #13467

tgodzik opened this issue Sep 3, 2021 · 6 comments · Fixed by #13530
Assignees
Labels
Milestone

Comments

@tgodzik
Copy link
Contributor

tgodzik commented Sep 3, 2021

Compiler version

3.1.0-RC1

Minimized code

object A {
  Array.concat@@
 }

when cursor at @@

Output

Exception in thread "pool-3-thread-1" java.lang.AssertionError: assertion failed: missing implicit parameter of type scala.reflect.ClassTag[A] after typer / Test / testOnly 6s
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:971)
        at dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:771)
        at dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:107)
        at dotty.tools.dotc.typer.Implicits.inferImplicitArg(Implicits.scala:845)
        at dotty.tools.dotc.typer.Implicits.inferImplicitArg$(Implicits.scala:771)
        at dotty.tools.dotc.typer.Typer.inferImplicitArg(Typer.scala:107)
        at dotty.tools.dotc.typer.Typer.implicitArgs$1(Typer.scala:3346)
        at dotty.tools.dotc.typer.Typer.addImplicitArgs$3(Typer.scala:3382)
        at dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$2(Typer.scala:3462)
        at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:3660)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3873)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3224)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2883)
        at dotty.tools.dotc.typer.Implicits.tryConversion$1(Implicits.scala:1056)
        at dotty.tools.dotc.typer.Implicits.typedImplicit(Implicits.scala:1087)
        at dotty.tools.dotc.typer.Implicits.typedImplicit$(Implicits.scala:771)
        at dotty.tools.dotc.typer.Typer.typedImplicit(Typer.scala:107)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.tryImplicit(Implicits.scala:1137)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.$anonfun$2(Implicits.scala:1432)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.typer.Implicits$ImplicitSearch.allImplicits(Implicits.scala:1432)
        at dotty.tools.dotc.interactive.Completion$Completer.implicitConversionTargets(Completion.scala:393)
        at dotty.tools.dotc.interactive.Completion$Completer.implicitConversionMemberCompletions(Completion.scala:280)
        at dotty.tools.dotc.interactive.Completion$Completer.selectionCompletions(Completion.scala:221)
        at dotty.tools.dotc.interactive.Completion$.computeCompletions(Completion.scala:115)
        at dotty.tools.dotc.interactive.Completion$.completions(Completion.scala:49)
        at scala.meta.internal.pc.CompletionProvider.completions(CompletionProvider.scala:39)
        at scala.meta.internal.pc.ScalaPresentationCompiler.complete$$anonfun$1(ScalaPresentationCompiler.scala:159)
        at scala.meta.internal.pc.CompilerAccess.withSharedCompiler(CompilerAccess.scala:137)
        at scala.meta.internal.pc.CompilerAccess.$anonfun$1(CompilerAccess.scala:87)
        at scala.meta.internal.pc.CompilerAccess.onCompilerJobQueue$$anonfun$1(CompilerAccess.scala:197)
        at scala.meta.internal.pc.CompilerJobQueue$Job.run(CompilerJobQueue.scala:139)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Expectation

Completion of:

concat[T: ClassTag](xss: Array[T]*): Array[T]

Similar thing happens with:

class A {
  1.until@@
}
@tgodzik
Copy link
Contributor Author

tgodzik commented Sep 3, 2021

Happened in scalameta/metals#3100

@tgodzik tgodzik added this to the 3.1.0 milestone Sep 8, 2021
@smarter
Copy link
Member

smarter commented Sep 9, 2021

Is this a regression? If so it'd be good to know the first nightly where this happened.

@smarter
Copy link
Member

smarter commented Sep 9, 2021

Also we would need a way to reproduce this in the dotty repo, like a unit test.

@tgodzik
Copy link
Contributor Author

tgodzik commented Sep 9, 2021

Weirdly enough this seems to work with test:

  @Test def untilMethod: Unit = {
    code"""|object A {
           |  Array.concat${m1}
           |}""".withSource
      .completion(m1, Set(("until", Method, "until(end: Int): Range")))
  }

I will see if maybe it was fixed in the nightlies

@Kordyjan Kordyjan modified the milestones: 3.1.0, 3.1.1 Sep 13, 2021
@prolativ
Copy link
Contributor

I tried to reproduce this and the problem doesn't occur in REPL. Also in my IDE this broke only after I upgraded Metals

@KacperFKorban KacperFKorban added the Spree Suitable for a future Spree label Sep 14, 2021
@tgodzik
Copy link
Contributor Author

tgodzik commented Sep 14, 2021

So the issue was caused by #13173

Any way we can avoid setting the Period:

val freshContext = ctx.fresh
            .setCompilationUnit(unit)
            .setPeriod(
              Period(
                driver.currentCtx.runId,
                driver.currentCtx.base.typerPhase.id
              )
            )

?

It seems that we should already be in the typerPhase, but the context doesn't seem to contain that information. I don't think it's quite intuitive that we need to force it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants