diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index cfd85c49cd0e..e0117300a9f8 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -313,10 +313,7 @@ trait Symbols { this: Context => newNakedSymbol[original.ThisName](original.coord) } val ttmap1 = ttmap.withSubstitution(originals, copies) - (originals, copies).zipped foreach {(original, copy) => - copy.denot = original.denot // preliminary denotation, so that we can access symbols in subsequent transform - } - (originals, copies).zipped foreach {(original, copy) => + (originals, copies).zipped foreach { (original, copy) => val odenot = original.denot val oinfo = original.info match { case ClassInfo(pre, _, parents, decls, selfInfo) => @@ -324,14 +321,27 @@ trait Symbols { this: Context => ClassInfo(pre, copy.asClass, parents, decls.cloneScope, selfInfo) case oinfo => oinfo } + + val completer = new LazyType { + def complete(denot: SymDenotation)(implicit ctx: Context): Unit = { + denot.info = oinfo // needed as otherwise we won't be able to go from Sym -> parents & etc + // Note that this is a hack, but hack commonly used in Dotty + // The same thing is done by other completers all the time + denot.info = ttmap1.mapType(oinfo) + denot.annotations = odenot.annotations.mapConserve(ttmap1.apply) + } + } + copy.denot = odenot.copySymDenotation( symbol = copy, owner = ttmap1.mapOwner(odenot.owner), - initFlags = odenot.flags &~ Frozen | Fresh, - info = ttmap1.mapType(oinfo), + initFlags = odenot.flags &~ (Frozen | Touched) | Fresh, + info = completer, privateWithin = ttmap1.mapOwner(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here. - annotations = odenot.annotations.mapConserve(ttmap1.apply)) + annotations = odenot.annotations) + } + copies } diff --git a/tests/pos/i1812.scala b/tests/pos/i1812.scala new file mode 100644 index 000000000000..653274883cf1 --- /dev/null +++ b/tests/pos/i1812.scala @@ -0,0 +1,12 @@ +class FF[R] { + def compose(): R = ??? +} + +class Test(x: Int) extends AnyVal { + def method: Unit = { + class Bla + class Foo extends FF[Bla] { + override def compose() = super[FF].compose() + } + } +} diff --git a/tests/pos/i1812b.scala b/tests/pos/i1812b.scala new file mode 100644 index 000000000000..492c545f154f --- /dev/null +++ b/tests/pos/i1812b.scala @@ -0,0 +1,11 @@ +class FF[R] { + def compose(): R = ??? +} + +class Test(x: Int) extends AnyVal { + def method: Unit = { + class Bla{ def bar:a.S = ???} + trait TRT{ type S} + val a: TRT = ??? + } +}