Skip to content

AssertionError on package object match #9331

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
sir-wabbit opened this issue Jul 9, 2020 · 1 comment · Fixed by #10007
Closed

AssertionError on package object match #9331

sir-wabbit opened this issue Jul 9, 2020 · 1 comment · Fixed by #10007

Comments

@sir-wabbit
Copy link

Minimized code

Probably directly related to #9289, if not a duplicate. The location of the failure is different but the underlying problem is similar.

// AE-7e0ebe9738cc74e6c98b4b5c59672b4d294bf00e
package object Foo {
  (1: Any) match {
    case Foo => 1
  }
}

Output (click arrow to expand)

exception occurred while compiling test.scala
java.lang.AssertionError: assertion failed: no member Foo . ==, members = Scope{
  final lazy module package object package: Foo.package$
  final module package object package$ extends Object with Serializable {this:
    Foo.package.type
   =>} at (Foo : Foo.type)
  class package: <notype>
} while compiling test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: no member Foo . ==, members = Scope{
  final lazy module package object package: Foo.package$
  final module package object package$ extends Object with Serializable {this:
    Foo.package.type
   =>} at (Foo : Foo.type)
  class package: <notype>
}
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.dotc.ast.Trees$Instance.applyOverloaded(Trees.scala:1559)
	at dotty.tools.dotc.ast.tpd$TreeOps$.equal$extension(tpd.scala:943)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.emitCondition(PatternMatcher.scala:695)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.emitCondWithPos$1(PatternMatcher.scala:874)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.$anonfun$11(PatternMatcher.scala:877)
	at scala.collection.immutable.List.foldRight(List.scala:352)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.emitWithMashedConditions$1(PatternMatcher.scala:878)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.emit(PatternMatcher.scala:883)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.default$1(PatternMatcher.scala:891)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.maybeEmitSwitch$1(PatternMatcher.scala:897)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.emit(PatternMatcher.scala:901)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.emit(PatternMatcher.scala:885)
	at dotty.tools.dotc.transform.PatternMatcher$Translator.translateMatch(PatternMatcher.scala:996)
	at dotty.tools.dotc.transform.PatternMatcher.transformMatch(PatternMatcher.scala:41)
	at dotty.tools.dotc.transform.MegaPhase.goMatch(MegaPhase.scala:746)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:345)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:406)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:409)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:409)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:339)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:251)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:404)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:409)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:409)
	at dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:356)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:359)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:406)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:409)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:409)
	at dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:356)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:359)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:415)
	at dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:427)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:318)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:319)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:180)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:190)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:198)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:205)
	at dotty.tools.dotc.Run.compileSources(Run.scala:142)
	at dotty.tools.dotc.Run.compile(Run.scala:124)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
	at dotty.tools.dotc.Driver.process(Driver.scala:194)
	at dotty.tools.dotc.Driver.process(Driver.scala:163)
	at dotty.tools.dotc.Driver.process(Driver.scala:175)
	at dotty.tools.dotc.Driver.main(Driver.scala:202)
	at dotty.tools.dotc.Main.main(Main.scala)
@griggt
Copy link
Contributor

griggt commented Oct 15, 2020

This no longer crashes in 0.28.0-bin-20201014-ca67e4d-NIGHTLY, but the error message could use some improvement:

-- [E007] Type Mismatch Error: i9331.scala:4:9 ---------------------------------
4 |    case Foo => 1
  |         ^^^
  |Found:    Foo.type
  |Required: ?{ == : ? }
  |Note that implicit extension methods cannot be applied because they are ambiguous;
  |both method ArrowAssoc in object Predef and method StringFormat in object Predef provide an extension method `==` on Foo.type

compare Scala 2.13.3:

i9331.scala:4: error: package Foo is not a value
    case Foo => 1

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

Successfully merging a pull request may close this issue.

3 participants