K2 Scripting: Skip base class params from resolution scope

The base class in scripting considered obsolete and therefore supported
via some ad-hoc mechanisms. In particular parameters to the base class
c-tor are passed via script provided properties. But in combination
with the resolution logic, this leads to issues described in KT-60452
This commits filters out such parameters from script resolution
scope and avoids this problem for now.
Bot it should be noted that proper diagnostics for properties shadowing
should still be implemented - see #KT-65809
#KT-60452 fixed
This commit is contained in:
Ilya Chernikov
2024-02-14 16:49:48 +01:00
committed by Space Team
parent 49559d2a5a
commit 9037975758
33 changed files with 138 additions and 58 deletions
@@ -93,7 +93,7 @@ class FirScriptConfiguratorExtensionImpl(
buildProperty {
moduleData = session.moduleData
source = this@configure.source?.fakeElement(KtFakeSourceElementKind.ScriptParameter)
origin = FirDeclarationOrigin.ScriptCustomization.Parameter
origin = FirDeclarationOrigin.ScriptCustomization.ParameterFromBaseClass
// TODO: copy type parameters?
returnTypeRef = baseCtorParameter.returnTypeRef
name = baseCtorParameter.name
@@ -119,8 +119,7 @@ class ScriptTemplateTest : TestCase() {
assertEqualsTrimmed(NUM_4_LINE + FIB_SCRIPT_OUTPUT_TAIL, out)
}
// Fails on K2, see KT-60452
fun testScriptWithoutParams() = expectTestToFailOnK2 {
fun testScriptWithoutParams() {
val messageCollector = TestMessageCollector()
val aClass = compileScript("without_params.kts", ScriptWithoutParams::class, null, messageCollector = messageCollector)
Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass)