Skip to content

Dotty deviation: failing to compile case class & package object with same name #435

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
DarkDimius opened this issue Mar 26, 2015 · 3 comments

Comments

@DarkDimius
Copy link
Contributor

case class FooBar(){}
package object FooBar{}
exception occured while indexing packageCase.scala
Exception in thread "main" scala.MatchError: PackageDef(Ident(FooBar),List(ModuleDef(package,Template(DefDef(<init>,List(),List(),TypeTree(EmptyTree),EmptyTree),List(),ValDef(_,EmptyTree,EmptyTree),List(EmptyTree))))) (of class dotty.tools.dotc.ast.Trees$PackageDef)
    at dotty.tools.dotc.typer.Namer$$anonfun$mergeCompanionDefs$1$4.apply(Namer.scala:408)
    at dotty.tools.dotc.typer.Namer$$anonfun$mergeCompanionDefs$1$4.apply(Namer.scala:405)
    at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:778)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:777)
    at dotty.tools.dotc.typer.Namer.mergeCompanionDefs$1(Namer.scala:405)
    at dotty.tools.dotc.typer.Namer.index(Namer.scala:422)
    at dotty.tools.dotc.typer.Namer.indexExpanded(Namer.scala:380)
    at dotty.tools.dotc.typer.Namer.index(Namer.scala:371)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$enterSyms$1.apply$mcV$sp(FrontEnd.scala:35)
    at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:18)
    at dotty.tools.dotc.typer.FrontEnd.enterSyms(FrontEnd.scala:33)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$2.apply(FrontEnd.scala:51)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$2.apply(FrontEnd.scala:51)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:51)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:50)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:47)
    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$compileSources$1.apply$mcV$sp(Run.scala:47)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:42)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:42)
    at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:68)
    at dotty.tools.dotc.Run.compileSources(Run.scala:41)
    at dotty.tools.dotc.Run.compile(Run.scala:32)
    at dotty.tools.dotc.Driver.doCompile(Driver.scala:20)
    at dotty.tools.dotc.Main$.doCompile(Main.scala:26)
    at dotty.tools.dotc.Driver.process(Driver.scala:31)
    at dotty.tools.dotc.Driver.main(Driver.scala:40)
    at dotty.tools.dotc.Main.main(Main.scala)
@DarkDimius DarkDimius self-assigned this Mar 26, 2015
DarkDimius added a commit to dotty-staging/dotty that referenced this issue Mar 26, 2015
DarkDimius added a commit to dotty-staging/dotty that referenced this issue Mar 26, 2015
@DarkDimius
Copy link
Contributor Author

I was able to fix failure in namer in 78af8a4, but now it fails in typer.

DarkDimius added a commit to dotty-staging/dotty that referenced this issue Mar 26, 2015
@DarkDimius DarkDimius changed the title MatchError in Namer Dotty deviation: failing to compile case class & package object with same name Mar 26, 2015
@DarkDimius
Copy link
Contributor Author

failure in typer:
https://github.com/lampepfl/dotty/blob/master/src/dotty/tools/dotc/typer/Typer.scala#L966

packageCase.scala:2: error: object FooBar is not a package
package object FooBar{}
                     ^
one error found

@odersky
Copy link
Contributor

odersky commented Feb 12, 2016

I don't think we should permit this, but #1079 improves the error message.

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