K2 Scripting: enable script diagnostic tests for FIR

also add script scopes test
This commit is contained in:
Ilya Chernikov
2022-11-10 12:04:38 +01:00
committed by Space Team
parent a3a1550933
commit 47448d779c
21 changed files with 571 additions and 304 deletions
@@ -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
@@ -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
@@ -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
}
@@ -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 {