Skip to content

Error with type of <outer> when inlining from TASTY #3608

Closed
@nicolasstucki

Description

@nicolasstucki

Fail to compile from TASTY

class A {
  class Foo {
    inline def inlineMeth: Unit = new Bar
  }
  class Bar
}

class B extends A {
  (new Foo).inlineMeth
}

Can be reproduced with

dotc <source>
dotc -decompile -Ycheck:all B
checking ./B.class after phase frontend
exception while typing  val A_this: B(B.this) = Foo_this.1_<outer> of class class dotty.tools.dotc.ast.Trees$ValDef # 41
exception while typing /* inlined from A*/ 
  {
     val Foo_this: B.this.Foo = new B.this.Foo()
     val A_this: B(B.this) = Foo_this.1_<outer>
    {
      new A_this.Bar()
      ()
    }
  } of class class dotty.tools.dotc.ast.Trees$Inlined # 56
exception while typing @scala.annotation.internal.SourceFile("tests/pos/i1990.scala")  class B ()
   extends
 A() { 
  /* inlined from A*/ 
    {
       val Foo_this: B.this.Foo = new B.this.Foo()
       val A_this: B(B.this) = Foo_this.1_<outer>
      {
        new A_this.Bar()
        ()
      }
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 29
exception while typing package <empty> {
  @scala.annotation.internal.SourceFile("tests/pos/i1990.scala")  class B ()
     extends
   A() { 
    /* inlined from A*/ 
      {
         val Foo_this: B.this.Foo = new B.this.Foo()
         val A_this: B(B.this) = Foo_this.1_<outer>
        {
          new A_this.Bar()
          ()
        }
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 36
*** error while checking ./B.class after phase frontend ***
Exception in thread "main" java.lang.AssertionError: assertion failed: found:    Foo_this.1_<outer>.type
required: B(B.this)


tree = Foo_this.1_<outer>
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:447)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1744)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:23)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1740)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:257)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1801)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedValDef$1(Typer.scala:1300)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:1294)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1663)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1726)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:272)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1744)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:23)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1740)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:257)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1766)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1789)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:434)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:623)
	at dotty.tools.dotc.typer.Typer.typedInlined(Typer.scala:1093)
	at dotty.tools.dotc.transform.TreeChecker$Checker.super$typedInlined(TreeChecker.scala:419)
	at dotty.tools.dotc.transform.TreeChecker$Checker.$anonfun$typedInlined$1(TreeChecker.scala:419)
	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:180)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedInlined(TreeChecker.scala:419)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1697)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1727)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:272)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1744)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:23)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1740)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:257)
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions