Is this runtime error an intended behavior? #24216
-
Search Keywords
SummaryWhen a package-private function is inlined outside its package, a Reproduction Code/src/main/scala/io/github/foo/internal/function.scala package io.github.foo.internal
private[foo] def packagePrivateMethod(): String = "Hello" /src/main/scala/io/github/foo/Main.scala package io.github.foo
// Even if you write it like this, the same error occurs.
// package internal {
// private[foo] def packagePrivateMethod(): String = "Hello"
// }
inline def hello(): Unit = {
val greeting = internal.packagePrivateMethod()
println(greeting)
}
@main def main(): Unit = {
hello()
} build.sbt
Error
Environment
Edited: After adding the import for package io.github.foo
import io.github.foo.internal.packagePrivateMethod
inline def hello(): Unit = {
val greeting = packagePrivateMethod()
println(greeting)
}
@main def main(): Unit = {
hello()
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
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. |
Beta Was this translation helpful? Give feedback.
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
harry1.scala
: