-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around scala/scala3#19019: patch the SelfDef of inner module cla…
…sses. Re-create the correct self type which is a term reference to the accompanying lazy val.
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
test-sources/src/main/scala/simple_trees/ObjectWithSelf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package simple_trees | ||
|
||
object ObjectWithSelf: | ||
object StaticObjectNoSelf: | ||
def foo: Any = this | ||
def bar: Any = this.foo | ||
end StaticObjectNoSelf | ||
|
||
object StaticObjectWithSelf: | ||
self => | ||
|
||
def foo: Any = self | ||
def bar: Any = self.foo | ||
end StaticObjectWithSelf | ||
|
||
class Container: | ||
object NonStaticObjectNoSelf: | ||
def foo: Any = this | ||
def bar: Any = this.foo | ||
end NonStaticObjectNoSelf | ||
|
||
object NonStaticObjectWithSelf: | ||
self => | ||
|
||
def foo: Any = self | ||
def bar: Any = self.foo // used to cause StackOverflow while resolving this in WholeClasspathSuite tests | ||
end NonStaticObjectWithSelf | ||
end Container | ||
|
||
def methodOwner(): Unit = | ||
object LocalObjectNoSelf: | ||
def foo: Any = this | ||
def bar: Any = this.foo | ||
end LocalObjectNoSelf | ||
|
||
object LocalObjectWithSelf: | ||
self => | ||
|
||
def foo: Any = self | ||
def bar: Any = self.foo | ||
end LocalObjectWithSelf | ||
end methodOwner | ||
end ObjectWithSelf |