diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 8c19a0874109..045a4f2eb365 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -443,7 +443,8 @@ object SymDenotations { val enclClassInfo = owner.asClass.classInfo enclClassInfo.selfInfo match { case self: Type => - owner.info = enclClassInfo.derivedClassInfo(selfInfo = refineSelfType(self)) + owner.info = enclClassInfo.derivedClassInfo( + selfInfo = refineSelfType(self.orElse(defn.AnyType))) case self: Symbol => self.info = refineSelfType(self.info) } @@ -1177,7 +1178,7 @@ object SymDenotations { case _ => NoType } - recur(owner.asClass.classInfo.selfType) + recur(owner.asClass.givenSelfType) } /** The non-private symbol whose name and type matches the type of this symbol diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 5dbad3614d0f..78549dd2c61b 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -511,7 +511,7 @@ class TreePickler(pickler: TastyPickler) { pickleParams(params) tree.parents.foreach(pickleTree) val cinfo @ ClassInfo(_, _, _, _, selfInfo) = tree.symbol.owner.info - if ((selfInfo ne NoType) || !tree.self.isEmpty) { + if (!tree.self.isEmpty) { writeByte(SELFDEF) pickleName(tree.self.name) diff --git a/tests/pos/i6822.scala b/tests/pos/i6822.scala new file mode 100644 index 000000000000..2076ef747af8 --- /dev/null +++ b/tests/pos/i6822.scala @@ -0,0 +1,3 @@ +class C { + opaque type T = Int +} \ No newline at end of file