Skip to content

Commit 2a24ac5

Browse files
demiurg906Space Team
authored andcommitted
[Test] Create test setup for IC and IR plugin referencing some external function
^KT-79504
1 parent 0877255 commit 2a24ac5

File tree

16 files changed

+265
-0
lines changed

16 files changed

+265
-0
lines changed

analysis/low-level-api-fir/tests-gen/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLReversedSandboxBackBoxTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

analysis/low-level-api-fir/tests-gen/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLSandboxBackBoxTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/plugin-sandbox/plugin-annotations/src/commonMain/kotlin/org/jetbrains/kotlin/plugin/sandbox/annotations.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,9 @@ annotation class EmitMetadata(val value: Int)
8181

8282
@Retention(AnnotationRetention.SOURCE)
8383
annotation class GenerateBodyUsingEmittedMetadata
84+
85+
/**
86+
* Signals [IrTransformerForICTesting] to insert a call of the specified function
87+
* in the annotated function
88+
*/
89+
annotation class CallSpecifiedFunction(val functionName: String)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package foo
2+
3+
var result = "Error"
4+
5+
fun functionToCall(): String {
6+
result = "OK"
7+
return "OK"
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package foo
2+
3+
var result = "Error"
4+
5+
fun functionToCall(): Int {
6+
result = "OK"
7+
return 1
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package foo
2+
3+
import org.jetbrains.kotlin.plugin.sandbox.CallSpecifiedFunction
4+
5+
@CallSpecifiedFunction("foo.functionToCall")
6+
fun test(): Int {
7+
val x = 1
8+
val y = 2
9+
return x + y
10+
}
11+
12+
fun box(): String {
13+
if (result != "Error") return result
14+
val testResult = test()
15+
if (testResult != 3) return "Error: $testResult"
16+
return result
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
================ Step #1 =================
2+
3+
Compiling files:
4+
src/a.kt
5+
End of files
6+
Exit code: OK
7+
8+
------------------------------------------
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test fails due to difference between bodies in b.kt in clean and IC builds

plugins/plugin-sandbox/plugin-sandbox-ic-test/tests-gen/org/jetbrains/kotlin/incremental/IncrementalK2JvmWithPluginCompilerRunnerTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/plugin-sandbox/src/org/jetbrains/kotlin/plugin/sandbox/ir/GeneratedDeclarationsIrBodyFiller.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class GeneratedDeclarationsIrBodyFiller : IrGenerationExtension {
2525
SourceElementChecker(pluginContext),
2626
MetadataExtensionEmitter(pluginContext),
2727
MetadataExtensionExtractor(pluginContext),
28+
IrTransformerForICTesting(pluginContext),
2829
)
2930

3031
for (transformer in transformers) {

0 commit comments

Comments
 (0)