Skip to content

Commit 44a89c9

Browse files
committed
Fix #6822: Fix self type handling for opaque types in classes
Two problems fixed: - selfInfo's can be NoType, so need to use the selfType as a refinement parent. - selfTypes for classes can be conjunctions of given self type and underlying type, so need to use givenselfType to extract the opaque alias.
1 parent a8b9b78 commit 44a89c9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
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(enclClassInfo.selfType))
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

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)