Closed
Description
Compiler version
3.3.1
Minimized code
MyRecord.java:
public record MyJavaRecord(String name, Integer age) {}
MyTest.scala
object MyScalaObject {
@main def test(): Unit = {
val javaRecord = new MyJavaRecord("Name", 50)
println(javaRecord.name())
println(javaRecord.age)
}
}
If MyJavaRecord is compiled with java compiler, and MyScalaObject is compiled with scala compiler using class file generated by Java compiler for the record, you'd get no syntax errors from scala compiler.
If MyJavaRecord & MyScalaObject are both compiled with scala compiler, first println would give you syntax error.
Expectation
When record is compiled via Scala compiler, it exposes accessor methods to the fields just like Java compiler. We should get no errors compiling both with scala compiler. Scala compiler should not enforce a syntax for java data type that is illegal by java compiler.