What are the guarantees for scala access qualifiers?

I have a class with this code:

package shop.orders.services.email private[services] class EmailService {...} 

Then in another package I use this class:

 package shop.ui import shop.orders.services.email.EmailService class PaymentConfirmation extends WithFacesContext { var emailService: EmailService = null 

Looking at the generated bytecode, there is no sign of any access modifier, which makes sense, since Java does not support such access restrictions. So, what happens if I create a library containing code similar to block one and try to compile the second block against the library - there is no chance that the compiler will fail because the information will be lost. Or is it contained in something like a manifest?

I am using Scala 2.9.2.

+8
scala scala-java-interop
source share
1 answer

You can reference EmailService in Java, but not Scala, because Scala stores the class signature as the scala.reflect.ScalaSignature annotation. The Scala compiler will fail with the following error:

the EmailService class in the package email cannot be accessed in the package shop.orders.services.email

+10
source share

All Articles