Is it bug or by design: The script can't access `p...
# scripting
w
Is it bug or by design: The script can't access
protected
in base class with new scripting version(KT 2.0+ library) Workaround `@Suppress("INVISIBLE_REFERENCE")`: works when compile and runtime.
p
can you show an example? let's check how it behaves in a non-scripting Gradle-based project
w
Base Class like:
Copy code
open class ScriptBase{
  protected fun setName(name:String)=Unit
}
Script:
Copy code
setName("")//get INVISIBLE_REFERENCE error
It seems many problem related to scripts `this`'s type.
Also I get another problem about this:
Copy code
//scriptA.kts
package t
data class Data(val v:Any)
And access in Another
Copy code
//scriptB.kts
t.ScriptA.Data() //GET ClassNotFound: t.Data
It seems the script is treated as KTFile, not a class. But Data is actually an inner class in Runtime.
I tried
-language-version=1.9
, and it works.
Get another KT2 bug in compiled script
WhiteList
.
Type argument is not within its bounds: should be subtype of 'Script'
Decompile to kotlin, it don't include superclass:
Copy code
public final class WhiteList {/**/}
It's correct when decompile to java (same bytecode):
Copy code
public final class WhiteList extends SAScript {/**/}