K2 Scripting: enable script diagnostic tests for FIR
also add script scopes test
This commit is contained in:
committed by
Space Team
parent
a3a1550933
commit
47448d779c
+396
-300
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
// FILE: script.kts
|
||||
|
||||
annotation class Ann
|
||||
|
||||
@<!UNRESOLVED_REFERENCE!>Ann<!><!SYNTAX!><!>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: f1.kt
|
||||
package test
|
||||
|
||||
class A
|
||||
class F1
|
||||
|
||||
// FILE: A.kts
|
||||
package test
|
||||
|
||||
val x = 1
|
||||
|
||||
class F1
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
val x = y
|
||||
|
||||
val y = 2
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSICS: +UNUSED_PARAMETER
|
||||
|
||||
fun foo(x: Int) = 1
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// documents inconsistency between scripts and classes, see DeclarationScopeProviderImpl
|
||||
|
||||
fun function() = 42
|
||||
val property = ""
|
||||
|
||||
class Nested {
|
||||
fun f() = function()
|
||||
fun g() = property
|
||||
}
|
||||
|
||||
|
||||
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>inner<!> class Inner {
|
||||
fun innerFun() = function()
|
||||
val innerProp = property
|
||||
fun innerThisFun() = this<!UNRESOLVED_LABEL!>@NestedInnerClass<!>.function()
|
||||
val innerThisProp = this<!UNRESOLVED_LABEL!>@NestedInnerClass<!>.property
|
||||
|
||||
inner class InnerInner {
|
||||
fun f() = <!UNRESOLVED_REFERENCE!>innerFun<!>()
|
||||
fun g() = <!UNRESOLVED_REFERENCE!>innerProp<!>
|
||||
fun h() = this@Inner.<!UNRESOLVED_REFERENCE!>innerFun<!>()
|
||||
fun i() = this@Inner.<!UNRESOLVED_REFERENCE!>innerProp<!>
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
// FIR_IDENTICAL
|
||||
private val s = "Hello"
|
||||
@@ -1 +1,2 @@
|
||||
// FIR_IDENTICAL
|
||||
val x = 1
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
val (a1, a2) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>A()<!>
|
||||
val (b1: Int, b2: Int) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>A()<!>
|
||||
val (c1) = <!COMPONENT_FUNCTION_MISSING, UNRESOLVED_REFERENCE!>unresolved<!>
|
||||
|
||||
<!WRONG_MODIFIER_TARGET!>private<!> val (d1) = <!COMPONENT_FUNCTION_MISSING!>A()<!>
|
||||
|
||||
val (e1, _) = <!COMPONENT_FUNCTION_MISSING!>A()<!>
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>a1<!>
|
||||
<!UNRESOLVED_REFERENCE!>a2<!>
|
||||
<!UNRESOLVED_REFERENCE!>e1<!>
|
||||
|
||||
class A {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = ""
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import java.util.ArrayList
|
||||
|
||||
val al: ArrayList<String>? = null
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
val (a, b, c) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING, NO_VALUE_FOR_PARAMETER!>A()<!>
|
||||
|
||||
class A(val a: Int) {
|
||||
operator fun component1() {}
|
||||
operator fun component2() {}
|
||||
operator fun component3() {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
var b = true
|
||||
|
||||
if (b) {
|
||||
val x = 3
|
||||
}
|
||||
|
||||
val y = <!UNRESOLVED_REFERENCE!>x<!>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public final class ScriptScopes : kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
||||
public constructor ScriptScopes(/*0*/ args: kotlin.Array<kotlin.String>)
|
||||
public final override /*1*/ /*fake_override*/ val args: kotlin.Array<kotlin.String>
|
||||
public final var b: kotlin.Boolean
|
||||
public final val y: [Error type: Not found recorded type for x]
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
val testVal: Int get() = 42
|
||||
|
||||
val testValNoType get() = 42
|
||||
|
||||
val String.testExtVal: Int get() = 42
|
||||
|
||||
val String.testExtValNoType get() = 42
|
||||
|
||||
var testVar: Int get() = 42; set(value) {}
|
||||
|
||||
var String.testExtVar: Int get() = 42; set(value) {}
|
||||
|
||||
val testValLineBreak: Int
|
||||
get() = 42
|
||||
|
||||
val testValLineBreakNoType
|
||||
get() = 42
|
||||
|
||||
<!MUST_BE_INITIALIZED!>val testValLineBreakSemi: Int<!>;
|
||||
<!VARIABLE_EXPECTED!>get()<!> = 42
|
||||
|
||||
<!MUST_BE_INITIALIZED!>val testValLineBreakSemiNoType<!>;
|
||||
<!VARIABLE_EXPECTED!>get()<!> = 42
|
||||
|
||||
var testVarLineBreak: Int
|
||||
get() = 42
|
||||
set(value) {}
|
||||
|
||||
var String.testExtVarLineBreak: Int
|
||||
get() = 42
|
||||
set(value) {}
|
||||
|
||||
<!MUST_BE_INITIALIZED!>var testVarLineBreakSemi: Int<!>;
|
||||
<!VARIABLE_EXPECTED!>get()<!> = 42
|
||||
<!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {}
|
||||
|
||||
<!EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT!>var String.testExtVarLineBreakSemi: Int<!>;
|
||||
<!VARIABLE_EXPECTED!>get()<!> = 42
|
||||
<!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {}
|
||||
@@ -0,0 +1,20 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Delegate {
|
||||
operator fun getValue(t: Any?, p: KProperty<*>): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>Delegate()<!>
|
||||
|
||||
class Foo {
|
||||
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>Delegate()<!>
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>Delegate()<!>
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
typealias TopLevelInScript = String
|
||||
|
||||
class C {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: script.kts
|
||||
|
||||
fun main(): Boolean {
|
||||
|
||||
Generated
+6
@@ -28034,6 +28034,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/script/resolveInitializerOfDestructuringDeclarationOnce.kts");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("scriptScopes.kts")
|
||||
public void testScriptScopes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/script/scriptScopes.kts");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SimpleScript.kts")
|
||||
public void testSimpleScript() throws Exception {
|
||||
|
||||
@@ -10,13 +10,18 @@ import java.io.File
|
||||
|
||||
private const val FIR_KT = ".fir.kt"
|
||||
private const val KT = ".kt"
|
||||
private const val FIR_KTS = ".fir.kts"
|
||||
private const val KTS = ".kts"
|
||||
|
||||
val File.isFirTestData: Boolean
|
||||
get() = name.endsWith(FIR_KT)
|
||||
get() = name.endsWith(FIR_KT) || name.endsWith((FIR_KTS))
|
||||
|
||||
val File.originalTestDataFile: File
|
||||
get() = if (isFirTestData) {
|
||||
parentFile.resolve("${name.removeSuffix(FIR_KT)}$KT")
|
||||
val originalTestDataFileName =
|
||||
if (name.endsWith(KTS)) "${name.removeSuffix(FIR_KTS)}$KTS"
|
||||
else "${name.removeSuffix(FIR_KT)}$KT"
|
||||
parentFile.resolve(originalTestDataFileName)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
@@ -25,7 +30,10 @@ val File.firTestDataFile: File
|
||||
get() = if (isFirTestData) {
|
||||
this
|
||||
} else {
|
||||
parentFile.resolve("${name.removeSuffix(KT)}$FIR_KT")
|
||||
val firTestDataFileName =
|
||||
if (name.endsWith(KTS)) "${name.removeSuffix(KTS)}$FIR_KTS"
|
||||
else "${name.removeSuffix(KT)}$FIR_KT"
|
||||
parentFile.resolve(firTestDataFileName)
|
||||
}
|
||||
|
||||
fun File.withExtension(extension: String): File {
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ fun generateJUnit5CompilerTests(args: Array<String>) {
|
||||
|
||||
testGroup(testsRoot = "compiler/fir/analysis-tests/tests-gen", testDataRoot = "compiler/testData") {
|
||||
testClass<AbstractFirDiagnosticTest>(suiteTestClassName = "FirOldFrontendDiagnosticsTestGenerated") {
|
||||
model("diagnostics/tests", excludedPattern = excludedFirTestdataPattern)
|
||||
model("diagnostics/tests", pattern = "^(.*)\\.kts?$", excludedPattern = excludedFirTestdataPattern)
|
||||
model("diagnostics/testsWithStdLib", excludedPattern = excludedFirTestdataPattern)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user