question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Top level implicit class with no arguments crashes in messages

See original GitHub issue

The source

implicit class Foo

crashes with

Exception in thread "main" java.lang.IndexOutOfBoundsException: 0
	at scala.collection.LinearSeqOptimized$class.apply(LinearSeqOptimized.scala:65)
	at scala.collection.immutable.List.apply(List.scala:84)
	at dotty.tools.dotc.reporting.diagnostic.messages$TopLevelImplicitClass.<init>(messages.scala:355)
	at dotty.tools.dotc.ast.desugar$$anonfun$17.apply(Desugar.scala:475)
	at dotty.tools.dotc.ast.desugar$$anonfun$17.apply(Desugar.scala:475)
	at dotty.tools.dotc.reporting.diagnostic.MessageContainer.contained(MessageContainer.scala:59)
	at dotty.tools.dotc.reporting.diagnostic.MessageContainer.message(MessageContainer.scala:42)
	at dotty.tools.dotc.reporting.diagnostic.MessageContainer.isNonSensical(MessageContainer.scala:71)
	at dotty.tools.dotc.reporting.HideNonSensicalMessages$class.isHidden(HideNonSensicalMessages.scala:17)
	at dotty.tools.dotc.reporting.ConsoleReporter.isHidden(ConsoleReporter.scala:13)
	at dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:232)
	at dotty.tools.dotc.reporting.Reporting$class.error(Reporter.scala:89)
	at dotty.tools.dotc.core.Contexts$Context.error(Contexts.scala:57)
	at dotty.tools.dotc.ast.desugar$.classDef(Desugar.scala:475)
	at dotty.tools.dotc.ast.desugar$.defTree(Desugar.scala:655)
	at dotty.tools.dotc.typer.Namer.expand(Namer.scala:364)
	at dotty.tools.dotc.typer.Namer$$anonfun$index$1.apply(Namer.scala:636)
	at dotty.tools.dotc.typer.Namer$$anonfun$index$1.apply(Namer.scala:636)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.typer.Namer.index(Namer.scala:636)
	at dotty.tools.dotc.typer.Namer.dotty$tools$dotc$typer$Namer$$recur$1(Namer.scala:427)
	at dotty.tools.dotc.typer.Namer.indexExpanded(Namer.scala:444)
	at dotty.tools.dotc.typer.Namer.index(Namer.scala:417)
	at dotty.tools.dotc.typer.FrontEnd$$anonfun$enterSyms$1.apply$mcV$sp(FrontEnd.scala:52)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:32)
	at dotty.tools.dotc.typer.FrontEnd.enterSyms(FrontEnd.scala:50)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:89)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:82)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:79)
	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:79)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:67)
	at dotty.tools.dotc.Run.compileSources(Run.scala:64)
	at dotty.tools.dotc.Run.compile(Run.scala:48)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
	at dotty.tools.dotc.Driver.process(Driver.scala:124)
	at dotty.tools.dotc.Driver.process(Driver.scala:93)
	at dotty.tools.dotc.Driver.process(Driver.scala:105)
	at dotty.tools.dotc.Driver.main(Driver.scala:132)
	at dotty.tools.dotc.Main.main(Main.scala)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Varunramcommented, May 19, 2017

EDIT: Sorry, some weird problem on my side. Got

1 |implicit class Foo //error
  |^^^^^^^^^^^^^^^^^^
  |An implicit class may not be top-level

as expected. Thanks a ton!

1reaction
nicolasstuckicommented, May 19, 2017

It will probably be good enough if you replace the exampleArgs by "..." if there are no args.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Better Implicit Search Errors: problematic cases wanted!
I will illustrate the problem of implicits parameterized by implicits with an experience report using Akka Http (note that the problem is not...
Read more >
scala - `implicit' modifier cannot be used for top-level objects
implicit cannot be used at the package level. You need to put your implicit objects inside another object that you can then import...
Read more >
Crashes - Android Developers
An app that is written using Java or Kotlin crashes if it throws an unhandled exception, represented by the Throwable class.
Read more >
Documentation - Classes - TypeScript
How classes work in TypeScript. ... the type annotation is optional, but will be an implicit any if not ... Crashes because "name"...
Read more >
Warning Options (Using the GNU Compiler Collection (GCC))
Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there may have been an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found