Change isStatic to isStaticOwner in hasLocalInstantiation#19803
Change isStatic to isStaticOwner in hasLocalInstantiation#19803dwijnand merged 1 commit intoscala:mainfrom
Conversation
|
If you keep the printing you can demonstrate the change in the output, which I think is good evidence: List(public T1$C1())
-List(public T2$$anon$1$C2(T2$$anon$1))
-List(public T3$C3$1(T3$))
-List(public T4$$anon$2$C4(T4$$anon$2))
+List(public T2$$anon$1$C2())
+List(public T3$C3$1())
+List(public T4$$anon$2$C4())
List(public T5$C5(T5))
List(public T6$$anon$3$C6())
List(public T7$C7$1()) |
|
Sounds good; I moved the test to |
| object T3 { def t3(): Unit = { class C3; test(classOf[C3]) } } | ||
| object T4 { def t4(): Unit = new AnyRef { class C4; test(classOf[C4]) } } | ||
|
|
||
| class T5 { class C5; test(classOf[C5]) } // outer ref currently not elided |
There was a problem hiding this comment.
I think "currently" isn't correct (and thus misleading). Classes that aren't defined in some kind of block are externally instantiable. So they are assumed to be public API, which means a change in the class's implementation can't break the API of that class's constructor.
There was a problem hiding this comment.
I see, this makes things clearer for me, thanks. I will clarify the comment.
But then, we should also not eliminate the outer reference in Got it; no need for an outer pointer in this case; the object can be accessed directly from its path.C1, should we? C1 is also publicly accessible and instantiable.
There was a problem hiding this comment.
Yeah, it's assumed that T1$ is instantiated only once, by val T1, as opposed to multiple T5 instances.
dwijnand
left a comment
There was a problem hiding this comment.
LGTM, except for 1 comment word 😄
Co-Authored-By: Dale Wijnand <dale.wijnand@gmail.com> Co-Authored-By: noti0na1 <noti0na1@users.noreply.github.com> Co-Authored-By: odersky <795990+odersky@users.noreply.github.com>
|
FYI: val Tiker = "tick"
class TickActor extends Actor {
def receive:Receive = {
case Tiker => // Do something
}
}Will generate a constrocutor with will not. |
Fixes #19569Related to #19569, but not a "fix". It actually allows eliminating outer references in even more cases.