K2 Scripting: add annotation resolving for scripts
#KT-62400 fixed
This commit is contained in:
committed by
Space Team
parent
31f9e9e7a8
commit
02dc3c4ddb
+15
@@ -394,6 +394,21 @@ abstract class AbstractFirSpecificAnnotationResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformScript(
|
||||
script: FirScript,
|
||||
data: Nothing?,
|
||||
): FirScript {
|
||||
if (shouldTransformDeclaration(script)) {
|
||||
computationSession.recordThatAnnotationsAreResolved(script)
|
||||
transformDeclaration(script, null).also {
|
||||
transformChildren(script) {
|
||||
script.transformStatements(this, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
return script
|
||||
}
|
||||
|
||||
inline fun withRegularClass(
|
||||
regularClass: FirRegularClass,
|
||||
action: () -> Unit
|
||||
|
||||
+11
@@ -33,6 +33,17 @@ class ScriptCompilerTest : TestCase() {
|
||||
assertTrue(res.reports.none { it.message.contains("nonsense") })
|
||||
}
|
||||
|
||||
fun testDeprecationAnnotation() {
|
||||
val res = compile("""
|
||||
@Deprecated("BECAUSE")
|
||||
fun deprecatedFunction() {}
|
||||
deprecatedFunction()
|
||||
""".trimIndent().toScriptSource()) {}
|
||||
|
||||
assertTrue(res is ResultWithDiagnostics.Success)
|
||||
assertTrue(res.reports.any { it.message.contains("deprecatedFunction(): Unit' is deprecated. BECAUSE") })
|
||||
}
|
||||
|
||||
fun testSimpleVarAccess() {
|
||||
val res = compileToClass(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user