Skip to content

Commit 4dc7db7

Browse files
authored
Fix #23194: Try to handle SkolemTypes in SingletonTypeTree during pickling (#23236)
Fix #23194
2 parents 65e5ce0 + 23c094e commit 4dc7db7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,13 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
716716
if passesConditionForErroringBestEffortCode(tree.hasType) then pickleType(tree.tpe)
717717
else pickleErrorType()
718718
case SingletonTypeTree(ref) =>
719-
writeByte(SINGLETONtpt)
720-
pickleTree(ref)
719+
val tp = ref.tpe
720+
val tp1 = tp.deskolemized
721+
if tp1 ne tp then
722+
pickleType(tp1)
723+
else
724+
writeByte(SINGLETONtpt)
725+
pickleTree(ref)
721726
case RefinedTypeTree(parent, refinements) =>
722727
if (refinements.isEmpty) pickleTree(parent)
723728
else {

tests/pos/i23194.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class R[T] extends annotation.StaticAnnotation
2+
3+
class A[T]:
4+
val next: A[T] = null
5+
val self: this.type = this
6+
val selfnext: this.next.type = this.next
7+
def f: (A[T] @R[this.type], A[T] @R[this.next.type]) = ???
8+
def g: (A[T] @R[self.type], A[T] @R[selfnext.type]) = ???
9+
10+
class Test:
11+
def test =
12+
val (a, b) = A[String]().f
13+
val (a2, b2) = A[String]().g
14+

0 commit comments

Comments
 (0)