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

Summoning top level in a trait crashes the compiler #19022

Open
XDracam opened this issue Nov 23, 2023 · 5 comments
Open

Summoning top level in a trait crashes the compiler #19022

XDracam opened this issue Nov 23, 2023 · 5 comments

Comments

@XDracam
Copy link

XDracam commented Nov 23, 2023

Compiler version

3.3.1

Minimized code

trait Bar

trait TestBug:
  summon[Bar]

Output (click arrow to expand)

scala: ## Exception when compiling 3 sources to C:\Users\Reusc\Desktop\thesis\code\scala\target\scala-3.3.1\classes
java.lang.AssertionError: assertion failed
scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
dotty.tools.dotc.ast.tpd$.TypeApply(tpd.scala:60)
dotty.tools.dotc.ast.tpd$TreeOps$.appliedToTypeTrees$extension(tpd.scala:985)
dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4255)
dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587)
dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:497)
dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897)
dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897)
dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:589)
dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:653)
dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:492)
dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:779)
dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:896)
dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1126)
dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:352)
dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:116)
dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:969)
dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1052)
dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3324)
dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1063)
dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1101)
dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:352)
dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:116)
dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3048)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184)
dotty.tools.dotc.typer.Implicits.tryConversion$1(Implicits.scala:1136)
dotty.tools.dotc.typer.Implicits.typedImplicit(Implicits.scala:1167)
dotty.tools.dotc.typer.Implicits.typedImplicit$(Implicits.scala:818)
dotty.tools.dotc.typer.Typer.typedImplicit(Typer.scala:116)
dotty.tools.dotc.typer.Implicits$ImplicitSearch.tryImplicit(Implicits.scala:1242)
dotty.tools.dotc.typer.Implicits$ImplicitSearch.rank$1(Implicits.scala:1341)
dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1511)
dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1539)
dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1547)
dotty.tools.dotc.typer.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1572)
dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:1060)
dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:818)
dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:116)
dotty.tools.dotc.typer.Implicits.inferView(Implicits.scala:856)
dotty.tools.dotc.typer.Implicits.inferView$(Implicits.scala:818)
dotty.tools.dotc.typer.Typer.inferView(Typer.scala:116)
dotty.tools.dotc.typer.Implicits.viewExists(Implicits.scala:831)
dotty.tools.dotc.typer.Implicits.viewExists$(Implicits.scala:818)
dotty.tools.dotc.typer.Typer.viewExists(Typer.scala:116)
dotty.tools.dotc.typer.Implicits.ignoredConvertibleImplicits$1$$anonfun$3(Implicits.scala:960)
scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
scala.collection.Iterator.isEmpty(Iterator.scala:466)
scala.collection.Iterator.isEmpty$(Iterator.scala:466)
scala.collection.AbstractIterator.isEmpty(Iterator.scala:1300)
scala.collection.View$Filter.isEmpty(View.scala:146)
scala.collection.IterableOnceOps.nonEmpty(IterableOnce.scala:833)
scala.collection.IterableOnceOps.nonEmpty$(IterableOnce.scala:833)
scala.collection.AbstractIterable.nonEmpty(Iterable.scala:933)
dotty.tools.dotc.reporting.MissingImplicitArgument.noChainConversionsNote$1(messages.scala:2838)
dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript$$anonfun$4(messages.scala:2846)
scala.Option.orElse(Option.scala:477)
dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript(messages.scala:2846)
dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:345)
dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:341)
dotty.tools.dotc.reporting.Message.message(Message.scala:345)
dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:322)
dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:16)
dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden$(HideNonSensicalMessages.scala:10)
dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8)
dotty.tools.dotc.reporting.Reporter.issueUnconfigured(Reporter.scala:156)
dotty.tools.dotc.reporting.Reporter.go$1(Reporter.scala:181)
dotty.tools.dotc.reporting.Reporter.issueIfNotSuppressed(Reporter.scala:200)
dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:203)
dotty.tools.dotc.report$.error(report.scala:68)
dotty.tools.dotc.typer.Typer.issueErrors$1$$anonfun$1(Typer.scala:3808)
scala.runtime.function.JProcedure3.apply(JProcedure3.java:15)
scala.runtime.function.JProcedure3.apply(JProcedure3.java:10)
scala.collection.LazyZip3.foreach(LazyZipOps.scala:248)
dotty.tools.dotc.typer.Typer.issueErrors$1(Typer.scala:3810)
dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:3832)
dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:3849)
dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4038)
dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4268)
dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188)
dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3237)
dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256)
dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2669)
dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3036)
dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3040)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188)
dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3210)
dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256)
dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2812)
dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3081)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188)
dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300)
dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44)
dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54)
scala.Function0.apply$mcV$sp(Function0.scala:42)
dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:440)
dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54)
dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
scala.collection.immutable.List.foreach(List.scala:333)
dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88)
dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
dotty.tools.dotc.Run.runPhases$1(Run.scala:262)
dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270)
dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279)
dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
dotty.tools.dotc.Run.compileUnits(Run.scala:279)
dotty.tools.dotc.Run.compileSources(Run.scala:194)
dotty.tools.dotc.Run.compile(Run.scala:179)
dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179)
sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177)
sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463)
sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:418)
sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:505)
sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:405)
sbt.internal.inc.Incremental$.apply(Incremental.scala:171)
sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
org.jetbrains.jps.incremental.scala.local.SbtCompiler.$anonfun$doCompile$4(SbtCompiler.scala:95)
scala.util.Try$.apply(Try.scala:210)
org.jetbrains.jps.incremental.scala.local.SbtCompiler.doCompile(SbtCompiler.scala:93)
org.jetbrains.jps.incremental.scala.local.SbtCompiler.compile(SbtCompiler.scala:21)
org.jetbrains.jps.incremental.scala.local.LocalServer.doCompile(LocalServer.scala:47)
org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:25)
org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:208)
org.jetbrains.jps.incremental.scala.remote.Main$.$anonfun$handleCommand$1(Main.scala:193)
org.jetbrains.jps.incremental.scala.remote.Main$.decorated$1(Main.scala:180)
org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:190)
org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:163)
org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:103)
org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
jdk.internal.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:568)
com.facebook.nailgun.NGSession.runImpl(NGSession.java:312)
com.facebook.nailgun.NGSession.run(NGSession.java:198)
@XDracam XDracam added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 23, 2023
@som-snytt
Copy link
Contributor

It does not reproduce with scalac.

The stacktrace implicates intellij.

org.jetbrains.jps.incremental.scala.local.SbtCompiler.$anonfun$doCompile$4(SbtCompiler.scala:95)

The compiler is just emitting the error. dotty.tools.dotc.report$.error(report.scala:68) Is it trying to add a helpful footnote about implicits?

@som-snytt
Copy link
Contributor

Seems to be same as #18999

Not closing because this minimization is arguably more elegant, and possibly is eligible for some sort of shortest bug award.

@XDracam
Copy link
Author

XDracam commented Nov 25, 2023

I finally got metals running in WSL (can't get it to work in windows for some reason) and:

  • things work in Metals in VSCode
  • I get the exception when implicit resolution fails in IntelliJ

@som-snytt
Copy link
Contributor

Maybe there is a difference in the reporter under metals. (The symptom is "downstream" of reporting an error.)

Because of -Wconf, I have become suspicious of all errors, which may reported, suppressed, or elevated.

I think the compiler needs an option for pure-report mode, by which all messaging is logged, irrespective of the "reporter" endpoint.

@szymon-rd szymon-rd added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 27, 2023
@som-snytt
Copy link
Contributor

The canonical ticket is #18650 fixed in #18719
It was fixed on 3.4 and backported to 3.3.2 LTS.
There are several duplicate tickets.

Ask and ye shall receive. pure-report mode was implemented as -Yno-enrich-error-messages.

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

No branches or pull requests

3 participants