- Notifications
You must be signed in to change notification settings - Fork1.1k
Is this runtime error an intended behavior?#24216
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Search Keywords
SummaryWhen a package-private function is inlined outside its package, a Reproduction Code/src/main/scala/io/github/foo/internal/function.scala packageio.github.foo.internalprivate[foo]defpackagePrivateMethod():String="Hello" /src/main/scala/io/github/foo/Main.scala packageio.github.foo// Even if you write it like this, the same error occurs.// package internal {// private[foo] def packagePrivateMethod(): String = "Hello"// }inlinedefhello():Unit= {valgreeting= internal.packagePrivateMethod() println(greeting)}@maindefmain():Unit= { hello()} build.sbt Error
Environment
Edited: After adding the import for packageio.github.fooimportio.github.foo.internal.packagePrivateMethodinlinedefhello():Unit= {valgreeting= packagePrivateMethod() println(greeting)}@maindefmain():Unit= { hello()} |
BetaWas this translation helpful?Give feedback.
All reactions
In that case, then it looks like a bug.
At typer, the call to qualified access looks like the following, where the special accessor takes the enclosing object, which should be the package object.
inline def hello(): Unit = { val greeting: String = io.github.foo.inline$packagePrivateMethod$i1(io.github.foo.internal)() println(greeting) }:Unit @main def main(): Unit = { io.github.foo.hello() } def inline$packagePrivateMethod$i1(x$0: io.github.foo.internal)(): String = x$0.packagePrivateMethod()For simplicity, I named my fileharry1.scala:
package io.github.foo.internal { final lazy module val harry1$package: io.…Replies: 1 comment 3 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
It's unusual to have more than one dot in a file name. That matters because the package object name is derived from its file name. There is a PR to introduce a warning:#22707 A related issue was that I don't recall if the use case (arbitrary file names) was intended or expected to be supported. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1👀 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Ah, sorry—that was my mistake. Incorrect: |
BetaWas this translation helpful?Give feedback.
All reactions
😄 1
-
In that case, then it looks like a bug. At typer, the call to qualified access looks like the following, where the special accessor takes the enclosing object, which should be the package object. For simplicity, I named my file |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1❤️ 1
-
Thank you for the answer! |
BetaWas this translation helpful?Give feedback.