-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
224 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import net.mamoe.kjbb.ir.JvmBlockingBridgeIrGenerationExtension | ||
import net.mamoe.kjbb.jvm.JvmBlockingBridgeCodegenJvmExtension | ||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension | ||
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension | ||
import org.jetbrains.kotlin.com.intellij.mock.MockProject | ||
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
|
||
@Suppress("unused") | ||
open class TestComponentRegistrar : ComponentRegistrar { | ||
|
||
override fun registerProjectComponents( | ||
project: MockProject, | ||
configuration: CompilerConfiguration | ||
) { | ||
IrGenerationExtension.registerExtension(project, JvmBlockingBridgeIrGenerationExtension()) | ||
ExpressionCodegenExtension.registerExtension(project, JvmBlockingBridgeCodegenJvmExtension()) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 2 additions & 10 deletions
12
...plugin/src/test/kotlin/TestInheritance.kt → ...gin/src/test/kotlin/ir/TestInheritance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
compiler-plugin/src/test/kotlin/jvm/TestCompilerInJvmBackend.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package jvm | ||
|
||
internal class TestCompilerInJvmBackend { | ||
|
||
//@Test | ||
fun `simple function in object`() = testJvmCompile( | ||
""" | ||
object TestData { | ||
@JvmBlockingBridge | ||
suspend fun test(): String{ | ||
return "OK" | ||
} | ||
fun main(): String = this.runFunction("test") | ||
} | ||
""" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jvm | ||
|
||
import compile | ||
import org.intellij.lang.annotations.Language | ||
import kotlin.test.assertEquals | ||
|
||
fun testJvmCompile( | ||
@Language("kt") | ||
source: String | ||
) { | ||
val result = compile(source, false) | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
val test = result.classLoader.loadClass("TestData") | ||
assertEquals( | ||
"OK", | ||
(test.kotlin.objectInstance!!).run { | ||
this::class.java.methods.first { it.name == "main" }.invoke(this) | ||
} as String) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.