Skip to content

Commit d3ebb98

Browse files
Merge pull request #6857 from dotty-staging/fix-#6822
Fix #6822: Fix self type handling for opaque types in classes
2 parents 5707343 + 6cb3e8f commit d3ebb98

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ object SymDenotations {
443443
val enclClassInfo = owner.asClass.classInfo
444444
enclClassInfo.selfInfo match {
445445
case self: Type =>
446-
owner.info = enclClassInfo.derivedClassInfo(selfInfo = refineSelfType(self))
446+
owner.info = enclClassInfo.derivedClassInfo(
447+
selfInfo = refineSelfType(self.orElse(defn.AnyType)))
447448
case self: Symbol =>
448449
self.info = refineSelfType(self.info)
449450
}
@@ -1177,7 +1178,7 @@ object SymDenotations {
11771178
case _ =>
11781179
NoType
11791180
}
1180-
recur(owner.asClass.classInfo.selfType)
1181+
recur(owner.asClass.givenSelfType)
11811182
}
11821183

11831184
/** The non-private symbol whose name and type matches the type of this symbol

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ class TreePickler(pickler: TastyPickler) {
511511
pickleParams(params)
512512
tree.parents.foreach(pickleTree)
513513
val cinfo @ ClassInfo(_, _, _, _, selfInfo) = tree.symbol.owner.info
514-
if ((selfInfo ne NoType) || !tree.self.isEmpty) {
514+
if (!tree.self.isEmpty) {
515515
writeByte(SELFDEF)
516516
pickleName(tree.self.name)
517517

tests/pos/i6822.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class C {
2+
opaque type T = Int
3+
}

0 commit comments

Comments
 (0)