File tree 2 files changed +54
-1
lines changed
tasty-query/shared/src/main/scala/tastyquery/reader/tasties
test-sources/src/main/scala/simple_trees
2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -685,7 +685,17 @@ private[tasties] class TreeUnpickler private (
685
685
case _ => readTypeTree
686
686
}
687
687
}
688
- val self = readSelf
688
+
689
+ val self0 = readSelf
690
+ val self = self0 match
691
+ case Some (orig @ SelfDef (name, tpt)) if cls.name.isObjectClassTypeName && cls.owner.isClass =>
692
+ // Work around https://github.com/lampepfl/dotty/issues/19019: replace with a correct SELFDEF
693
+ val owner = cls.owner.asClass
694
+ val fixedTpt = TypeWrapper (TermRef (owner.thisType, cls.name.sourceObjectName))(orig.pos)
695
+ Some (SelfDef (name, fixedTpt)(orig.pos))
696
+ case _ =>
697
+ self0
698
+
689
699
cls.withGivenSelfType(self.map(_.tpt.toType))
690
700
// The first entry is the constructor
691
701
val cstr = readStat.asInstanceOf [DefDef ]
Original file line number Diff line number Diff line change
1
+ package simple_trees
2
+
3
+ object ObjectWithSelf :
4
+ object StaticObjectNoSelf :
5
+ def foo : Any = this
6
+ def bar : Any = this .foo
7
+ end StaticObjectNoSelf
8
+
9
+ object StaticObjectWithSelf :
10
+ self =>
11
+
12
+ def foo : Any = self
13
+ def bar : Any = self.foo
14
+ end StaticObjectWithSelf
15
+
16
+ class Container :
17
+ object NonStaticObjectNoSelf :
18
+ def foo : Any = this
19
+ def bar : Any = this .foo
20
+ end NonStaticObjectNoSelf
21
+
22
+ object NonStaticObjectWithSelf :
23
+ self =>
24
+
25
+ def foo : Any = self
26
+ def bar : Any = self.foo // used to cause StackOverflow while resolving this in WholeClasspathSuite tests
27
+ end NonStaticObjectWithSelf
28
+ end Container
29
+
30
+ def methodOwner (): Unit =
31
+ object LocalObjectNoSelf :
32
+ def foo : Any = this
33
+ def bar : Any = this .foo
34
+ end LocalObjectNoSelf
35
+
36
+ object LocalObjectWithSelf :
37
+ self =>
38
+
39
+ def foo : Any = self
40
+ def bar : Any = self.foo
41
+ end LocalObjectWithSelf
42
+ end methodOwner
43
+ end ObjectWithSelf
You can’t perform that action at this time.
0 commit comments