Skip to content

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

@faucct

Description

@faucct

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions