Skip to content

Early Java pickling applies Scala visibility to Java #12744

@szeiger

Description

@szeiger

Early Java pickling (using -Ypickle-java) applies the wrong (Scala) visibility when typing Java sources. Given P.scala:

package com.example.test

private[test] class P

and U.java

package com.example.test2;

import com.example.test.P;

public class U {
    private P p;
}
$ ~/scala/scala-2.13.10/bin/scalac -Ypickle-java -Ypickle-write p-pickle.jar -d p.jar P.scala U.java
U.java:6: error: not found: type P
    private P p;
            ^
1 error

The Scala package-private (or private-within) visibility is erased in the bytecode, making the class public for Java. This normally allows U.java to be compiled with Zinc in a mixed project. The extra Java typing introduced by -Ypickle-java breaks this. I encountered this originally in 2.12.15 and it is reproducible in 2.12.17 and 2.13.10.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions