Repository navigation
Is this runtime error an intended behavior? #24216
Answered
by
som-snytt
harry0000
asked this question in
General Question
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()
} |
Answered by
som-snytt
Oct 21, 2025
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. |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: