Skip to content

private override has the same erasure #7749

Closed
@sir-wabbit

Description

@sir-wabbit

minimized code

trait A {
    def foo = 4
}
object B extends A {
    private[this] def foo = 0
}
Stack trace
checking testing/Test.scala after phase frontend
checking testing/Test.scala after phase inlinedPositions
checking testing/Test.scala after phase staging
checking testing/Test.scala after phase posttyper
checking testing/Test.scala after phase pickler
checking testing/Test.scala after phase reifyQuotes
checking testing/Test.scala after phase MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, completeJavaEnums}
checking testing/Test.scala after phase MegaPhase{checkStatic, elimRepeated, expandSAMs, protectedAccessors, extmethods, cacheAliasImplicits, shortcutImplicits, byNameClosures, hoistSuperArgs, classOf, refchecks}
checking testing/Test.scala after phase MegaPhase{elimOpaque, tryCatchPatterns, patternMatcher, explicitOuter, explicitSelf, stringInterpolatorOpt, crossCast}
checking testing/Test.scala after phase MegaPhase{pruneErasedDefs, vcInlineMethods, seqLiterals, intercepted, getters, elimByName, collectNullableFields, elimOuterSelect, augmentScala2Traits, resolveSuper, functionXXLForwarders, genericTuples, arrayConstructors}
checking testing/Test.scala after phase erasure
checking testing/Test.scala after phase MegaPhase{elimErasedValueType, vcElideAllocations, arrayApply, elimPolyFunction, tailrec, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}
exception while typing @scala.annotation.internal.SourceFile("testing/Test.scala") final module class
  B$
() extends Object, A, java.io.Serializable {
  super()
  def foo(): Int = super[A].foo()
  private def writeReplace(): Object =
    new scala.runtime.ModuleSerializationProxy(classOf[B$])
  private def foo(): Int = 0
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 1529
exception while typing package <empty> {
  @scala.annotation.internal.SourceFile("testing/Test.scala") trait A() extends
    Object
   {
    def foo(): Int = 4
  }
  final lazy module val B: B$ = new B$()
  @scala.annotation.internal.SourceFile("testing/Test.scala") final module class

  B$() extends Object, A, java.io.Serializable {
    super()
    def foo(): Int = super[A].foo()
    private def writeReplace(): Object =
      new scala.runtime.ModuleSerializationProxy(classOf[B$])
    private def foo(): Int = 0
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 1530
*** error while checking testing/Test.scala after phase capturedVars ***
exception occurred while compiling testing/Test.scala
class dotty.tools.dotc.reporting.diagnostic.messages$Error at testing/Test.scala:<71..71>: Double definition:
def foo(): Int in object B and
private def foo(): Int in object B at line 5
have the same type after erasure. while compiling testing/Test.scala
Exception in thread "main" class dotty.tools.dotc.reporting.diagnostic.messages$Error at testing/Test.scala:<71..71>: Double definition:
def foo(): Int in object B and
private def foo(): Int in object B at line 5
have the same type after erasure.
	at dotty.tools.dotc.reporting.Reporting.error(Reporter.scala:135)
	at dotty.tools.dotc.core.Contexts$Context.error(Contexts.scala:75)
	at dotty.tools.dotc.typer.Checking.doubleDefError$2(Checking.scala:878)
	at dotty.tools.dotc.typer.Checking.checkDecl$5$$anonfun$4(Checking.scala:879)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:553)
	at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:551)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:921)
	at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:891)
	at dotty.tools.dotc.typer.Checking.checkDecl$1(Checking.scala:886)
	at dotty.tools.dotc.typer.Checking.checkNoDoubleDeclaration$$anonfun$2(Checking.scala:891)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:305)
	at dotty.tools.dotc.core.Scopes$Scope.foreach(Scopes.scala:93)
	at dotty.tools.dotc.typer.Checking.checkNoDoubleDeclaration(Checking.scala:891)
	at dotty.tools.dotc.typer.Typer.checkNoDoubleDeclaration(Typer.scala:82)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1773)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedClassDef(TreeChecker.scala:415)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2089)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2156)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:301)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2193)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2205)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:286)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2232)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2276)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:475)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1890)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2130)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2157)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:301)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2193)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2205)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:286)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2290)
	at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:121)
	at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:94)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
	at scala.collection.immutable.List.map(List.scala:219)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161)
	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:171)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:186)
	at dotty.tools.dotc.Run.compileSources(Run.scala:123)
	at dotty.tools.dotc.Run.compile(Run.scala:106)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
	at dotty.tools.dotc.Driver.process(Driver.scala:189)
	at dotty.tools.dotc.Driver.process(Driver.scala:158)
	at dotty.tools.dotc.Driver.process(Driver.scala:170)
	at dotty.tools.dotc.Driver.main(Driver.scala:197)
	at dotty.tools.dotc.Main.main(Main.scala)

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