diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index 5464dce4f331..236079c9e1b9 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -141,9 +141,15 @@ object Annotations { apply(defn.AliasAnnot, List( ref(TermRef.withSigAndDenot(sym.owner.thisType, sym.name, sym.signature, sym)))) - def makeChild(sym: Symbol)(implicit ctx: Context) = - deferred(defn.ChildAnnot, - implicit ctx => New(defn.ChildAnnotType.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil)) + def makeChild(delayedSym: Context => Symbol)(implicit ctx: Context): Annotation = { + def makeChildLater(implicit ctx: Context) = { + val sym = delayedSym(ctx) + New(defn.ChildAnnotType.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil) + } + deferred(defn.ChildAnnot, implicit ctx => makeChildLater(ctx)) + } + + def makeChild(sym: Symbol)(implicit ctx: Context): Annotation = makeChild(_ => sym) def makeSourceFile(path: String)(implicit ctx: Context) = apply(defn.SourceFileAnnot, Literal(Constant(path))) diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 712148756c7e..595ae12a90eb 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -829,8 +829,13 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas assert(tag == CHILDREN) val end = readNat() + readIndex val target = readSymbolRef() - while (readIndex != end) - target.addAnnotation(Annotation.makeChild(readSymbolRef())) + while (readIndex != end) { + val start = readIndex + readNat() // skip reference for now + target.addAnnotation( + Annotation.makeChild(implicit ctx => + atReadPos(start, () => readSymbolRef()))) + } } /* Read a reference to a pickled item */ diff --git a/tests/new/projection.scala b/tests/new/projection.scala new file mode 100644 index 000000000000..766c6f41cdeb --- /dev/null +++ b/tests/new/projection.scala @@ -0,0 +1,4 @@ +class C { type T } +object test { + def x: C#T = ??? +} diff --git a/tests/pos/i2391/Containers.scala b/tests/pos/i2391/Containers.scala new file mode 100644 index 000000000000..557018404a5d --- /dev/null +++ b/tests/pos/i2391/Containers.scala @@ -0,0 +1,10 @@ +// Containers.scala +package foo + +trait ParentContainer { + sealed trait Entry +} + +class ChildContainer extends ParentContainer { + trait LazyEntry extends Entry +} diff --git a/tests/pos/i2391/User.scala b/tests/pos/i2391/User.scala new file mode 100644 index 000000000000..e7ccf859f41a --- /dev/null +++ b/tests/pos/i2391/User.scala @@ -0,0 +1,6 @@ +// User.scala +package foo + +trait User { + type Entry <: ChildContainer#Entry +}