I can call `internal` symbols from other modules u...
# compiler
m
I can call
internal
symbols from other modules using `@Suppress("INVISIBLE_MEMBER")`or
"INVISIBLE_REFERENCE"
. However that does not work for internal setter on a property. How can I suppress
Cannot assign to ...: the setter is internal in ...
?
Solved by going though java wrapper, as java ignores
internal
. I'd still like to go through with just kotlin though.
e
what are the internal symbols you want to use and can you set
-Xfriend-paths
or associated compilations to allow access instead?
m
In compose app I set `ScrollState.maxValue`(in my custom scrolling layout implementation). This is in library so I can't use friend-paths.
e
across modules it would make more sense to use
@RequiresOptIn
than try to abuse
internal
m
Maybe but I did not make that API
y
This:
Copy code
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
fun main() {
    kotlinx.coroutines.timeSource = null
}
worked for me to access an
internal var
in kotlinx coroutines. Are you specifically accessing something with an
internal set
?
m
Yup, it is
public var internal set
y
Found it! You need
@Suppress("INVISIBLE_SETTER")
. I found out from the DefaultErrorMessages.java, which lists nearly all the warnings and errors that the compiler can produce, therefore you can search for any error in that file and find its tag.
m
Wow, thanks! I was looking for that in source too but quite a different file.
d
Actually you can add
-Xrender-internal-diagnostic-names
compiler flag to render diagnostic names in build or enable internal mode in IDEA, so it will render this name in pop-up with diagnostic message
👍 1
👌 1
But don't forget that suppressing errors may be quite unstable
343 Views