Do not generate properties for script parameters if there is template definition
This commit is contained in:
@@ -76,6 +76,20 @@ class ScriptTest2 {
|
||||
aClass!!.getConstructor(Integer.TYPE).newInstance(4)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptWithoutParams() {
|
||||
val aClass = compileScript("without_params.kts", ScriptWithoutParams::class, null)
|
||||
Assert.assertNotNull(aClass)
|
||||
aClass!!.getConstructor(Integer.TYPE).newInstance(4)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptWithOverridenParam() {
|
||||
val aClass = compileScript("overriden_parameter.kts", ScriptBaseClassWithOverridenProperty::class, null)
|
||||
Assert.assertNotNull(aClass)
|
||||
aClass!!.getConstructor(Integer.TYPE).newInstance(4)
|
||||
}
|
||||
|
||||
private fun compileScript(
|
||||
scriptPath: String,
|
||||
scriptBase: KClass<out Any>,
|
||||
@@ -167,17 +181,27 @@ class TestKotlinScriptDependenciesResolver : ScriptDependenciesResolver {
|
||||
@ScriptTemplateDefinition(
|
||||
scriptFilePattern =".*\\.kts",
|
||||
resolver = TestKotlinScriptDependenciesResolver::class)
|
||||
abstract class ScriptWithIntParam(num: Int)
|
||||
abstract class ScriptWithIntParam(val num: Int)
|
||||
|
||||
@ScriptTemplateDefinition(
|
||||
scriptFilePattern =".*\\.kts",
|
||||
resolver = TestKotlinScriptDependenciesResolver::class)
|
||||
abstract class ScriptWithClassParam(param: TestParamClass)
|
||||
abstract class ScriptWithClassParam(val param: TestParamClass)
|
||||
|
||||
@ScriptTemplateDefinition(
|
||||
scriptFilePattern =".*\\.kts",
|
||||
resolver = TestKotlinScriptDependenciesResolver::class)
|
||||
abstract class ScriptWithBaseClass(num: Int, passthrough: Int) : TestDSLClassWithParam(passthrough)
|
||||
abstract class ScriptWithBaseClass(val num: Int, passthrough: Int) : TestDSLClassWithParam(passthrough)
|
||||
|
||||
@ScriptTemplateDefinition(
|
||||
scriptFilePattern =".*\\.kts",
|
||||
resolver = TestKotlinScriptDependenciesResolver::class)
|
||||
abstract class ScriptWithoutParams(num: Int)
|
||||
|
||||
@ScriptTemplateDefinition(
|
||||
scriptFilePattern =".*\\.kts",
|
||||
resolver = TestKotlinScriptDependenciesResolver::class)
|
||||
abstract class ScriptBaseClassWithOverridenProperty(override val num: Int) : TestClassWithOverridableProperty(num)
|
||||
|
||||
@Target(AnnotationTarget.FILE)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
|
||||
@@ -29,3 +29,5 @@ fun TestDSLInterface.fibCombine(f: (Int) -> Int, n: Int) = if (n < 2) 1 else f(n
|
||||
open class TestDSLClassWithParam(val offset: Int)
|
||||
|
||||
fun TestDSLClassWithParam.fibCombine(f: (Int) -> Int, n: Int) = if (n < 2) offset else f(n - 1) + f(n - 2)
|
||||
|
||||
open class TestClassWithOverridableProperty(open val num: Int)
|
||||
Reference in New Issue
Block a user