You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add @publicInBinary annotation and -WunstableInlineAccessors
Introduces [SIP-52](scala/improvement-proposals#58) as experimental feature.
A binary API is a definition that is annotated with `@publicInBinary` or overrides a definition annotated with `@publicInBinary`. This annotation can be placed on `def`, `val`, `lazy val`, `var`, `object`, and `given` definitions. A binary API will be publicly available in the bytecode. It cannot be used on `private`/`private[this]` definitions.
This is useful in combination with inline definitions. If an inline definition refers to a private/protected definition marked as `@publicInBinary` it does not need to use an accessor. We still generate the accessors for binary compatibility but do not use them.
If the linting option `-WunstableInlineAccessors` is enabled, then a warning will be emitted if an inline accessor is generated. The warning will guide the user to the use of `@publicInBinary`.
@@ -148,7 +153,7 @@ abstract class AccessProxies {
148
153
defaccessorIfNeeded(tree: Tree)(usingContext):Tree= tree match {
149
154
casetree: RefTreeif needsAccessor(tree.symbol) =>
150
155
if (tree.symbol.isConstructor) {
151
-
report.error("Implementation restriction: cannot use private constructors in inlineable methods", tree.srcPos)
156
+
report.error("Cannot use private constructors in inline methods. You can use @publicInBinary to make constructor accessible in inline methods.", tree.srcPos)
152
157
tree // TODO: create a proper accessor for the private constructor
0 commit comments