Skip to content

Failure Ychecking path depended outer after explicitOuter #10253

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 Nov 9, 2020 · 2 comments
Closed

Failure Ychecking path depended outer after explicitOuter #10253

nicolasstucki opened this issue Nov 9, 2020 · 2 comments

Comments

@nicolasstucki
Copy link
Contributor

Minimized code

def foo(qc: QC): Unit =
  object treeMap extends qc.reflect.TreeMap

trait QC:
  val reflect: Reflection
  trait Reflection:
    trait TreeMap:
      def transformTree: Unit = ???

Output (click arrow to expand)

 sbt:scala3> run Foo.scala -Ycheck:all
      [warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
      [info] running (fork) dotty.tools.dotc.Main -classpath ~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.3/scala-library-2.13.3.jar:dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.0.0-M2/scala3-library_3.0.0-M2-3.0.0-M2-bin-SNAPSHOT.jar Foo.scala -Ycheck:all
      checking Foo.scala after phase typer
      checking Foo.scala after phase inlinedPositions
      checking Foo.scala after phase posttyper
      checking Foo.scala after phase staging
      checking Foo.scala after phase pickler
      checking Foo.scala after phase reifyQuotes
      checking Foo.scala after phase MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, betaReduce}
      checking Foo.scala after phase MegaPhase{elimRepeated, expandSAMs, protectedAccessors, extmethods, cacheAliasImplicits, byNameClosures, hoistSuperArgs, refchecks}
      checking Foo.scala after phase MegaPhase{elimOpaque, tryCatchPatterns, patternMatcher, explicitOuter, explicitSelf, stringInterpolatorOpt}
      exception while typing final def QC$Reflection$TreeMap$$$outer: QC.this.Reflection = qc.reflect of class class dotty.tools.dotc.ast.Trees$DefDef # -1
      exception while typing final module class treeMap$() extends Object(), qc.reflect.TreeMap {
        final def QC$Reflection$TreeMap$$$outer: QC.this.Reflection = qc.reflect
      } of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
      exception while typing {
        final lazy module val treeMap: treeMap$ = new treeMap$()
        final module class treeMap$() extends Object(), qc.reflect.TreeMap {
          final def QC$Reflection$TreeMap$$$outer: QC.this.Reflection = qc.reflect
        }
        ()
      } of class class dotty.tools.dotc.ast.Trees$Block # -1
      exception while typing def foo(qc: QC): Unit =
        {
          final lazy module val treeMap: treeMap$ = new treeMap$()
          final module class treeMap$() extends Object(), qc.reflect.TreeMap {
            final def QC$Reflection$TreeMap$$$outer: QC.this.Reflection = qc.reflect
          }
          ()
        } of class class dotty.tools.dotc.ast.Trees$DefDef # -1
      exception while typing @scala.annotation.internal.SourceFile(
        "Foo.scala"
      ) final module class Macro$package$() extends Object() {
        private def writeReplace(): AnyRef =
          new scala.runtime.ModuleSerializationProxy(classOf[Macro$package.type])
        def foo(qc: QC): Unit =
          {
            final lazy module val treeMap: treeMap$ = new treeMap$()
            final module class treeMap$() extends Object(), qc.reflect.TreeMap {
              final def QC$Reflection$TreeMap$$$outer: QC.this.Reflection = qc.reflect
            }
            ()
          }
      } of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
      exception while typing package <empty> {
        @scala.annotation.internal.SourceFile(
          "Foo.scala"
        ) trait QC() extends Object {
          val reflect: QC.this.Reflection
          trait Reflection() extends Object {
            trait TreeMap() extends Object {
              def transformTree: Unit = ???
              final def QC$Reflection$TreeMap$$$outer: QC.this.Reflection
            }
            final def QC$Reflection$$$outer: QC
          }
        }
        final lazy module val Macro$package: Macro$package$ = new Macro$package$()
        @scala.annotation.internal.SourceFile(
          "Foo.scala"
        ) final module class Macro$package$() extends Object() {
          private def writeReplace(): AnyRef =
            new scala.runtime.ModuleSerializationProxy(classOf[Macro$package.type])
          def foo(qc: QC): Unit =
            {
              final lazy module val treeMap: treeMap$ = new treeMap$()
              final module class treeMap$() extends Object(), qc.reflect.TreeMap {
                final def QC$Reflection$TreeMap$$$outer: QC.this.Reflection =
                  qc.reflect
              }
              ()
            }
        }
      } of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
      *** error while checking Foo.scala after phase stringInterpolatorOpt ***
      exception occurred while compiling Foo.scala
      java.lang.AssertionError: assertion failed: Found:    (qc.reflect : qc.Reflection)
      Required: QC.this.Reflection
      found: ??
      expected: trait Reflection in trait QC with trait Reflection, flags = <trait> <noinits> <touched>, underlying = QC.this.Reflection, Object {...}
      tree = qc.reflect while compiling Foo.scala
      Exception in thread "main" java.lang.AssertionError: assertion failed: Found:    (qc.reflect : qc.Reflection)
      Required: QC.this.Reflection
      found: ??
      expected: trait Reflection in trait QC with trait Reflection, flags = <trait> <noinits> <touched>, underlying = QC.this.Reflection, Object {...}
      tree = qc.reflect
              at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
              at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:560)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2591)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2595)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:317)
              at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2710)
              at dotty.tools.dotc.typer.Typer.$anonfun$31(Typer.scala:1976)
              at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:217)
              at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1976)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$2$$anonfun$1(TreeChecker.scala:477)
              at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:199)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$1(TreeChecker.scala:480)
              at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:199)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef(TreeChecker.scala:481)
              at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2438)
              at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2521)
              at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:333)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2591)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2595)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:317)
              at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2617)
              at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2666)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:521)
              at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2121)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedClassDef(TreeChecker.scala:453)
              at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2449)
              at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2453)
              at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2521)
              at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:333)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2591)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2595)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:317)
              at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2617)
              at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2666)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:521)
              at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:890)
              at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:894)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$2$$anonfun$1(TreeChecker.scala:503)
              at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:199)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$1(TreeChecker.scala:503)
              at dotty.tools.dotc.transform.TreeChecker$Checker.withBlock(TreeChecker.scala:227)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock(TreeChecker.scala:503)
              at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2469)
              at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2522)
              at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:333)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2591)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2595)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:317)
              at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2710)
              at dotty.tools.dotc.typer.Typer.$anonfun$31(Typer.scala:1976)
              at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:217)
              at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1976)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$2$$anonfun$1(TreeChecker.scala:477)
              at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:199)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$1(TreeChecker.scala:480)
              at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:199)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef(TreeChecker.scala:481)
              at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2438)
              at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2521)
              at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:333)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2591)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2595)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:317)
              at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2617)
              at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2666)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:521)
              at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2121)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedClassDef(TreeChecker.scala:453)
              at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2449)
              at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2453)
              at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2521)
              at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:333)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2591)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2595)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:317)
              at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2617)
              at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2666)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:521)
              at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2246)
              at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2493)
              at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2522)
              at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:333)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2591)
              at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2595)
              at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:317)
              at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2710)
              at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:151)
              at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:120)
              at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:296)
              at scala.collection.immutable.List.map(List.scala:246)
              at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
              at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
              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:195)
              at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
              at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
              at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
              at dotty.tools.dotc.Run.compileUnits(Run.scala:210)
              at dotty.tools.dotc.Run.compileSources(Run.scala:147)
              at dotty.tools.dotc.Run.compile(Run.scala:129)
              at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
              at dotty.tools.dotc.Driver.process(Driver.scala:195)
              at dotty.tools.dotc.Driver.process(Driver.scala:164)
              at dotty.tools.dotc.Driver.process(Driver.scala:176)
              at dotty.tools.dotc.Driver.main(Driver.scala:203)
              at dotty.tools.dotc.Main.main(Main.scala)
@odersky
Copy link
Contributor

odersky commented Nov 10, 2020

I see the problem but I don't think it matters. There's a loss of path-dependent typing very close before erasure, where the whole thing gets erased anyway. Can we not put things in an exclude list instead? I have a long tail of things to resolve, before I could get to this.

@odersky odersky removed their assignment Nov 10, 2020
@smarter
Copy link
Member

smarter commented Nov 10, 2020

Can we not put things in an exclude list instead?

If it's intented to be part of scala3-library that would mean we can't compile the whole library with -Ycheck:all like everything else which would be unfortunate.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 12, 2020
In theory it should be inside of the QuoteContext but this is blocked by scala#10253.
We take this first step to cleanup the `scala.tasty` package
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 12, 2020
In theory it should be inside of the QuoteContext but this is blocked by scala#10253.
We take this first step to cleanup the `scala.tasty` package

Also fix code that uses Reflection directly.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 12, 2020
In theory it should be inside of the QuoteContext but this is blocked by scala#10253.
We take this first step to cleanup the `scala.tasty` package

Also fix code that uses Reflection directly.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 12, 2020
In theory it should be inside of the QuoteContext but this is blocked by scala#10253.
We take this first step to cleanup the `scala.tasty` package

Also fix code that uses Reflection directly.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 12, 2020
In theory it should be inside of the QuoteContext but this is blocked by scala#10253.
We take this first step to cleanup the `scala.tasty` package

Also fix code that uses Reflection directly.
michelou pushed a commit to michelou/scala3 that referenced this issue Nov 12, 2020
In theory it should be inside of the QuoteContext but this is blocked by scala#10253.
We take this first step to cleanup the `scala.tasty` package

Also fix code that uses Reflection directly.
odersky added a commit to dotty-staging/dotty that referenced this issue Nov 13, 2020
Use the actual prefix of the base type rather than an applied ThisType
@odersky odersky self-assigned this Nov 14, 2020
nicolasstucki added a commit that referenced this issue Nov 16, 2020
Fix #10253: Fix result type of outer accessors
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