Open
Description
Here is a case where the compiler accepts a structural type ascription and generates code which throws at runtime. It happens on at least 2.12.8 and 2.13.0:
package failure.otherpackage;
public class JavaClass {
protected void foo() {
}
}
package failure.somepackage
import scala.language.reflectiveCalls
import failure.otherpackage._
object Main extends App {
val j : { def foo(): Unit } = new JavaClass // accepted by the compiler
j.foo() // throws an exception at runtime
}
This is probably related to #5352, which is ancient and closed. The associated fix (bedb33fd7cb) appears to have regressed. It seems the compiler treats all "non-private" access modifies as "public" when deciding whether a type matches a structural description.