Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to access package-private symbols from .sc files #1392

Open
faucct opened this issue Dec 28, 2023 · 1 comment
Open

unable to access package-private symbols from .sc files #1392

faucct opened this issue Dec 28, 2023 · 1 comment

Comments

@faucct
Copy link

faucct commented Dec 28, 2023

The execution model says that the script files are wrapped in a package object – https://ammonite.io/#ExecutionModel

Otherwise, the source code for this script is then wrapped in a package/object wrapper, corresponding to the path to the script from the current script's enclosing folder. For example, a script at path foo/bar/baz/Qux.sc will be wrapped in:

package foo.bar.baz
object Qux{
  // script code
}

Despite this, I am unable to access the package-private symbols from the same package:

// org/apache/spark/sql/Foo.sc
import org.apache.spark.sql.Dataset

def foo(): Unit = {
    println(Dataset)
    println("foo")
}

def bar(): Unit = {
    println(Dataset)
}

almond jupyter kernel's cell:

import $file.org.apache.spark.sql.Foo

Foo.foo()

execution error:

Compiling /home/jovyan/shared/users/faucct/org/apache/spark/sql/Foo.sc
/home/jovyan/shared/users/faucct/org/apache/spark/sql/Foo.sc:4: object Dataset in package sql cannot be accessed in package org.apache.spark.sql
    println(Dataset)
            ^
/home/jovyan/shared/users/faucct/org/apache/spark/sql/Foo.sc:9: not found: value Dataset
    println(Dataset)
            ^
Compilation Failed

Though, I am not sure if the problem is on your side or Almond's.
Putting the file three directories higher also does not help.

@faucct
Copy link
Author

faucct commented Dec 29, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant