Closed
Description
Fail to compile
class Bar(ctor : Int => Int)
class Foo extends Bar(x => x)
Can be reproduced with
dotc <source>
dotc -decompile -Ycheck:all Foo
Exception in thread "main" java.lang.AssertionError: assertion failed: bad owner; method $anonfun has owner value <local Foo>, expected was constructor Foo
owner chain = method $anonfun, value <local Foo>, class Foo, package <empty>, package <root>, ctxOwners = constructor Foo, constructor Foo, constructor Foo, package <empty>, package <root>, package <root>, package <root>, package <root>, package <root>, package <root>, package <root>, package <root>, <none>, <none>, <none>, <none>, <none>
at scala.Predef$.assert(Predef.scala:219)
at dotty.tools.dotc.transform.TreeChecker$Checker.checkOwner(TreeChecker.scala:362)
at dotty.tools.dotc.transform.TreeChecker$Checker.$anonfun$typedStats$1(TreeChecker.scala:430)
at dotty.tools.dotc.transform.TreeChecker$Checker.$anonfun$typedStats$1$adapted(TreeChecker.scala:429)
at scala.collection.immutable.List.foreach(List.scala:389)
at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:429)
at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:623)
at dotty.tools.dotc.typer.Typer.$anonfun$typedBlock$1(Typer.scala:626)
at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:625)
at dotty.tools.dotc.transform.TreeChecker$Checker.super$typedBlock(TreeChecker.scala:416)
at dotty.tools.dotc.transform.TreeChecker$Checker.$anonfun$typedBlock$1(TreeChecker.scala:416)
at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:180)
at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock(TreeChecker.scala:416)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1685)
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.ProtoTypes$FunProto.$anonfun$typedArg$1(ProtoTypes.scala:241)
at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:219)
at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:241)
at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:642)
at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:640)
at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:412)
at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:451)
at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:233)
at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:543)
at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:641)
at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:697)
at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$7(Applications.scala:722)
at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:1809)
at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$1(Applications.scala:723)