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

MissingType crash for code completions #16228

Closed
prolativ opened this issue Oct 21, 2022 · 10 comments · Fixed by #16267
Closed

MissingType crash for code completions #16228

prolativ opened this issue Oct 21, 2022 · 10 comments · Fixed by #16267
Labels
area:ide area:repl itype:bug itype:crash regression This worked in a previous version but doesn't anymore

Comments

@prolativ
Copy link
Contributor

prolativ commented Oct 21, 2022

Compiler version

Breaks with: 3.2.0, 3.nightly
Used to work with: 3.1.3

Minimized code

scala-cli repl --dep "com.softwaremill.sttp.client3::core:3.8.3" -S 3.2.0
scala> import sttp.client3.<TAB>

Output (click arrow to expand)

Oct 21, 2022 10:22:50 AM org.jline.utils.Log logr
INFO: Error while finding completion candidates
dotty.tools.dotc.core.TypeError: Could not read definition of class HttpClientAsyncBackend in /Users/mpalka/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/client3/core_3/3.8.3/core_3-3.8.3.jar(sttp/client3/HttpClientAsyncBackend.class)
An exception was encountered:
  dotty.tools.dotc.core.MissingType: 
Run with -Ydebug-unpickling to see full stack trace.
	at dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$Completer$$_$fail$1(TreeUnpickler.scala:128)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.liftedTree1$1(TreeUnpickler.scala:137)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:137)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:171)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:373)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:64)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.is(SymDenotations.scala:110)
	at dotty.tools.dotc.interactive.Completion$Completer.dotty$tools$dotc$interactive$Completion$Completer$$include(Completion.scala:471)
	at dotty.tools.dotc.interactive.Completion$Completer$$anon$4.applyOrElse(Completion.scala:504)
	at dotty.tools.dotc.interactive.Completion$Completer$$anon$4.applyOrElse(Completion.scala:503)
	at scala.collection.immutable.List.collect(List.scala:275)
	at scala.collection.immutable.List.collect(List.scala:79)
	at dotty.tools.dotc.interactive.Completion$Completer.accessibleMembers(Completion.scala:505)
	at dotty.tools.dotc.interactive.Completion$Completer.directMemberCompletions(Completion.scala:339)
	at dotty.tools.dotc.interactive.Completion$.computeCompletions(Completion.scala:149)
	at dotty.tools.dotc.interactive.Completion$.completions(Completion.scala:48)
	at dotty.tools.repl.ReplDriver.completions$$anonfun$1(ReplDriver.scala:240)
	at scala.util.Either.map(Either.scala:382)
	at dotty.tools.repl.ReplDriver.completions(ReplDriver.scala:241)
	at dotty.tools.repl.ReplDriver.$anonfun$1(ReplDriver.scala:151)
	at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4412)
	at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4378)
	at org.jline.reader.impl.LineReaderImpl.expandOrComplete(LineReaderImpl.java:4317)
	at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3809)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:679)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:468)
	at dotty.tools.repl.JLineTerminal.readLine(JLineTerminal.scala:74)
	at dotty.tools.repl.ReplDriver.readLine$1(ReplDriver.scala:156)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:166)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:171)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:192)
	at dotty.tools.repl.ReplDriver.runBody$$anonfun$1(ReplDriver.scala:180)
	at dotty.tools.runner.ScalaClassLoader$.asContext(ScalaClassLoader.scala:80)
	at dotty.tools.repl.ReplDriver.runBody(ReplDriver.scala:180)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:171)
	at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:133)
	at dotty.tools.repl.Main$.main(Main.scala:7)
	at dotty.tools.repl.Main.main(Main.scala)

Output with -Ydebug-unpickling:

Oct 21, 2022 10:24:21 AM org.jline.utils.Log logr
INFO: Error while finding completion candidates
dotty.tools.dotc.core.MissingType: 
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$sigName(TypeErasure.scala:815)
	at dotty.tools.dotc.core.TypeErasure$.sigName(TypeErasure.scala:204)
	at dotty.tools.dotc.core.Signature.$anonfun$2(Signature.scala:111)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Signature.prependTermParams(Signature.scala:111)
	at dotty.tools.dotc.core.Types$MethodOrPoly.computeSignature$2(Types.scala:3565)
	at dotty.tools.dotc.core.Types$MethodOrPoly.signature(Types.scala:3582)
	at dotty.tools.dotc.core.Types$MethodOrPoly.computeSignature$2(Types.scala:3557)
	at dotty.tools.dotc.core.Types$MethodOrPoly.signature(Types.scala:3582)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:615)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:605)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.atSignature(Denotations.scala:647)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.atSignature(Denotations.scala:645)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1299)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1373)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1215)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1373)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1210)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1373)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$19(TreeUnpickler.scala:962)
	at dotty.tools.tasty.TastyReader.collectWhile(TastyReader.scala:137)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTemplate(TreeUnpickler.scala:965)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:883)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:802)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.liftedTree1$1(TreeUnpickler.scala:133)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:137)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:171)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:373)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:64)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.is(SymDenotations.scala:110)
	at dotty.tools.dotc.interactive.Completion$Completer.dotty$tools$dotc$interactive$Completion$Completer$$include(Completion.scala:471)
	at dotty.tools.dotc.interactive.Completion$Completer$$anon$4.applyOrElse(Completion.scala:504)
	at dotty.tools.dotc.interactive.Completion$Completer$$anon$4.applyOrElse(Completion.scala:503)
	at scala.collection.immutable.List.collect(List.scala:275)
	at scala.collection.immutable.List.collect(List.scala:79)
	at dotty.tools.dotc.interactive.Completion$Completer.accessibleMembers(Completion.scala:505)
	at dotty.tools.dotc.interactive.Completion$Completer.directMemberCompletions(Completion.scala:339)
	at dotty.tools.dotc.interactive.Completion$.computeCompletions(Completion.scala:149)
	at dotty.tools.dotc.interactive.Completion$.completions(Completion.scala:48)
	at dotty.tools.repl.ReplDriver.completions$$anonfun$1(ReplDriver.scala:240)
	at scala.util.Either.map(Either.scala:382)
	at dotty.tools.repl.ReplDriver.completions(ReplDriver.scala:241)
	at dotty.tools.repl.ReplDriver.$anonfun$1(ReplDriver.scala:151)
	at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4412)
	at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4378)
	at org.jline.reader.impl.LineReaderImpl.expandOrComplete(LineReaderImpl.java:4317)
	at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3809)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:679)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:468)
	at dotty.tools.repl.JLineTerminal.readLine(JLineTerminal.scala:74)
	at dotty.tools.repl.ReplDriver.readLine$1(ReplDriver.scala:156)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:166)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:171)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:192)
	at dotty.tools.repl.ReplDriver.runBody$$anonfun$1(ReplDriver.scala:180)
	at dotty.tools.runner.ScalaClassLoader$.asContext(ScalaClassLoader.scala:80)
	at dotty.tools.repl.ReplDriver.runBody(ReplDriver.scala:180)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:171)
	at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:133)
	at dotty.tools.repl.Main$.main(Main.scala:7)
	at dotty.tools.repl.Main.main(Main.scala)
@prolativ prolativ added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label area:repl labels Oct 21, 2022
@prolativ
Copy link
Contributor Author

This also affects metals

@prolativ prolativ added area:ide regression This worked in a previous version but doesn't anymore and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 21, 2022
@prolativ
Copy link
Contributor Author

It seems the error doesn't occur if there's at least one character after the dot, e.g.

scala> import sttp.client3.q<TAB>

@prolativ
Copy link
Contributor Author

On the other hand this does crash

import sttp.client3.H<TAB>

This might be more specifically connected with the HttpClientAsyncBackend class

@prolativ
Copy link
Contributor Author

Also it seems that there's no crash if I set the java version to at least 11 (I'm using 8 by default). However in scala 3.1.3 this worked for any java version

@odersky
Copy link
Contributor

odersky commented Oct 23, 2022

Nothing obvious comes to mind when looking at the stacktraces. I think the best way forward would be a bisect.

odersky added a commit to dotty-staging/dotty that referenced this issue Nov 1, 2022
@prolativ
Copy link
Contributor Author

I tried to bisect this and it looks like the regression was introduced in this commit ee22b6a by incrementing TASTy minor version. I have no idea how this could have caused the bug but indeed, when I checked out to this branch, publishLocal'ed the compiler and used this version to run the REPL via scala-cli I got the error as in the bug report. When I downgraded MinorVersion from TastyFormat.scala and went through the same procedure, there was no crash.

@odersky
Copy link
Contributor

odersky commented Nov 23, 2022

I see no way a TASTY minor version could influence this.

I think we should merge #16287 then since it fixes the problem.

@dwijnand
Copy link
Member

scala-cli seems partially to blame here, it seems? Using Coursier launch on Java 8 doesn't seem to fail for me:

$ cs launch scala3:3.2.0 -- -cp $(cs fetch -p com.softwaremill.sttp.client3::core:3.8.3)
Welcome to Scala 3.2.0 (1.8.0_345, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> import sttp.client3.BasicRequestBody

scala>
$ scala-cli repl --dep "com.softwaremill.sttp.client3::core:3.8.3" -S 3.2.0
Welcome to Scala 3.2.0 (1.8.0_345, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> import sttp.client3.Nov 23, 2022 5:48:56 PM org.jline.utils.Log logr
INFO: Error while finding completion candidates
dotty.tools.dotc.core.TypeError: Could not read definition of class HttpClientSyncBackend in /Users/dnw/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/client3/core_3/3.8.3/core_3-3.8.3.jar(sttp/client3/HttpClientSyncBackend.class)
...

@prolativ
Copy link
Contributor Author

@dwijnand when running coursier you set the scala version only for launch but

cs fetch -p com.softwaremill.sttp.client3::core:3.8.3

seems to resolve dependencies for scala 2.13 by default.
With

cs launch --jvm 8 scala3:3.2.0 -- -cp $(cs fetch --scala 3.2.0 -p com.softwaremill.sttp.client3::core:3.8.3)

the completion crashes as it does with scala-cli

@dwijnand
Copy link
Member

Ah, thank you. Nice one, man.

little-inferno pushed a commit to little-inferno/dotty that referenced this issue Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:ide area:repl itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants