Skip to content

Survive duplicated symbols generated by 2.13 #11991

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/Printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ object Printers {
val quotePickling = noPrinter
val plugins = noPrinter
val refcheck = noPrinter
val scala2unpickle = noPrinter
val simplify = noPrinter
val staging = noPrinter
val subtyping = noPrinter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.annotation.switch
import reporting._
import config.Printers.scala2unpickle

object Scala2Unpickler {

Expand Down Expand Up @@ -491,8 +492,14 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
sym.setFlag(Scala2x)
if (!(isRefinementClass(sym) || isUnpickleRoot(sym) || sym.is(Scala2Existential))) {
val owner = sym.owner
if (owner.isClass)
owner.asClass.enter(sym, symScope(owner))
if owner.isClass then
val scope = symScope(owner)
if !(sym.isType && scope.lookup(sym.name).exists) then
owner.asClass.enter(sym, scope)
else
scala2unpickle.println(i"duplicate symbol ${sym.showLocated}")
// Scala 2.13 seems sometimes generates duplicate type parameters with the same owner
// For instance, in i11173. In this case, we cannot proceed with entering.
}
sym
}
Expand Down
14 changes: 14 additions & 0 deletions tests/pos/i11173/Lib.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

// Compile this with Scala 2.13
package i11173

trait DU[A, B]
trait H[F[_]]

trait Foo[E] {
def foo: H[({type L[A] = DU[E, A]})#L]
}

trait Bar[E] extends Foo[E] {
def bar = foo // important note: return type not specified
}
5 changes: 5 additions & 0 deletions tests/pos/i11173/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

import i11173.Bar

def test(x: Bar[_]): Unit = ()