Skip to content

Anonymous class lifted in wrong package #3000

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
nicolasstucki opened this issue Aug 21, 2017 · 0 comments
Closed

Anonymous class lifted in wrong package #3000

nicolasstucki opened this issue Aug 21, 2017 · 0 comments

Comments

@nicolasstucki
Copy link
Contributor

class Foo {
  new Object { }
}

package bar { }

fails Ycheck with

checking Foo.scala after phase TreeTransform:{linkScala2Impls, lambdaLift, elimStaticThis, flatten, restoreScopes}
exception while typing package bar {
  private <static> class $anon extends Object { 
    def <init>(): Unit = 
      {
        super()
        ()
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 416
exception while typing package <empty> {
  @scala.annotation.internal.SourceFile("Foo.scala") class Foo extends Object { 
    def <init>(): Unit = 
      {
        super()
        {
          new Object{...}(): Object
        }
        ()
      }
  }
  package bar {
    private <static> class $anon extends Object { 
      def <init>(): Unit = 
        {
          super()
          ()
        }
    }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 417
*** error while checking Foo.scala after phase restoreScopes ***

exception occurred while compiling Foo.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: bad owner; anonymous class Object{...} has owner package <empty>, expected was package bar
owner chain = anonymous class Object{...}, package <empty>, package <root>, ctxOwners = package bar, package <empty>, package <root>, package <root>, package <root>, package <root>, package <root>, package <root>, package <root>, <none>, <none>, <none>, <none>
	at scala.Predef$.assert(Predef.scala:170)
	at dotty.tools.dotc.transform.TreeChecker$Checker.dotty$tools$dotc$transform$TreeChecker$Checker$$checkOwner(TreeChecker.scala:360)
	at dotty.tools.dotc.transform.TreeChecker$Checker$$anonfun$typedStats$1.apply(TreeChecker.scala:429)
	at dotty.tools.dotc.transform.TreeChecker$Checker$$anonfun$typedStats$1.apply(TreeChecker.scala:428)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:428)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1517)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1504)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1504)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1657)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1674)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:275)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1689)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1687)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:140)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1687)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:260)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1722)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1734)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:433)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1517)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1504)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1504)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1657)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1674)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:275)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1689)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1687)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:140)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1687)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:260)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1746)
	at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:133)
	at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:105)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:283)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:281)
	at scala.collection.immutable.List.map(List.scala:284)
	at dotty.tools.dotc.core.Phases$Phase$class.runOn(Phases.scala:281)
	at dotty.tools.dotc.transform.TreeChecker.runOn(TreeChecker.scala:48)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:81)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:78)
	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:78)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:66)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:66)
	at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:66)
	at dotty.tools.dotc.Run.compileSources(Run.scala:63)
	at dotty.tools.dotc.Run.compile(Run.scala:47)
	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)
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

1 participant