diff --git a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt
index b0445f2f75c..f0f290dd24b 100644
--- a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt
+++ b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.kt
@@ -12,24 +12,28 @@ import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.psi.KtFile
+import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
import org.jetbrains.kotlin.test.InTextDirectivesUtils
object DirectiveBasedActionUtils {
- fun checkForUnexpectedErrors(file: KtFile) {
+ fun checkForUnexpectedErrors(file: KtFile, diagnosticsProvider: (KtFile) -> Diagnostics = { it.analyzeWithContent().diagnostics }) {
if (InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// DISABLE-ERRORS").isNotEmpty()) {
return
}
val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ERROR:").sorted()
- val actualErrors = file.analyzeWithContent().diagnostics
- .filter { it.getSeverity() == Severity.ERROR }
- .map { DefaultErrorMessages.render(it).replace("\n", "
") }
- .sorted()
+ val diagnostics = diagnosticsProvider(file)
+ val actualErrors = diagnostics
+ .filter { it.severity == Severity.ERROR }
+ .map { DefaultErrorMessages.render(it).replace("\n", "
") }
+ .sorted()
- UsefulTestCase.assertOrderedEquals("All actual errors should be mentioned in test data with // ERROR: directive. But no unnecessary errors should be me mentioned",
- actualErrors,
- expectedErrors)
+ UsefulTestCase.assertOrderedEquals(
+ "All actual errors should be mentioned in test data with // ERROR: directive. But no unnecessary errors should be me mentioned",
+ actualErrors,
+ expectedErrors
+ )
}
fun checkAvailableActionsAreExpected(file: PsiFile, availableActions: Collection) {
diff --git a/idea/testData/codeInsight/outOfBlock/FunBlock.kt b/idea/testData/codeInsight/outOfBlock/FunBlock.kt
index 745785e378f..f709745f94e 100644
--- a/idea/testData/codeInsight/outOfBlock/FunBlock.kt
+++ b/idea/testData/codeInsight/outOfBlock/FunBlock.kt
@@ -1,4 +1,8 @@
// OUT_OF_CODE_BLOCK: FALSE
+fun run(block: () -> Int): Int {
+ return block()
+}
+
fun some(): Int = run { 12 + }
// TYPE: 1
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/FunInFun.kt b/idea/testData/codeInsight/outOfBlock/FunInFun.kt
index 73b292e48ff..30b2dd5d719 100644
--- a/idea/testData/codeInsight/outOfBlock/FunInFun.kt
+++ b/idea/testData/codeInsight/outOfBlock/FunInFun.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
+// TYPE: 0
fun main() {
fun some = 12
}
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/FunInInitBlock.kt b/idea/testData/codeInsight/outOfBlock/FunInInitBlock.kt
index 516d4366943..81e279c69b9 100644
--- a/idea/testData/codeInsight/outOfBlock/FunInInitBlock.kt
+++ b/idea/testData/codeInsight/outOfBlock/FunInInitBlock.kt
@@ -1,5 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
-
+// ERROR: Unresolved reference: a
class A {
init {
fun f() {
diff --git a/idea/testData/codeInsight/outOfBlock/FunNoBody.kt b/idea/testData/codeInsight/outOfBlock/FunNoBody.kt
index 663d4b06899..148c234d1a3 100644
--- a/idea/testData/codeInsight/outOfBlock/FunNoBody.kt
+++ b/idea/testData/codeInsight/outOfBlock/FunNoBody.kt
@@ -1,2 +1,4 @@
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Unresolved reference: a12
+
fun some() = 12
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/FunNoType_Block.kt b/idea/testData/codeInsight/outOfBlock/FunNoType_Block.kt
index b03b36904e7..79414e4b54a 100644
--- a/idea/testData/codeInsight/outOfBlock/FunNoType_Block.kt
+++ b/idea/testData/codeInsight/outOfBlock/FunNoType_Block.kt
@@ -1,6 +1,7 @@
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Function 'test' must have a body
+// TYPE: \b
+
fun test() {
}
-
-// TYPE: \b
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer.kt b/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer.kt
index 2779088aabd..8595bae31d1 100644
--- a/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer.kt
+++ b/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer.kt
@@ -1,5 +1,6 @@
// OUT_OF_CODE_BLOCK: TRUE
// (Investigation starts from parent)
+// ERROR: Unresolved reference: a12
fun test() : Int = 12
diff --git a/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer_Expression.kt b/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer_Expression.kt
index 3c36f684642..19ee0cc3961 100644
--- a/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer_Expression.kt
+++ b/idea/testData/codeInsight/outOfBlock/FunWithType_Initializer_Expression.kt
@@ -1,3 +1,4 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a12
fun test() : Int = 12 + 12
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/InAntonymsObjectDeclaration.kt b/idea/testData/codeInsight/outOfBlock/InAnonymousObjectDeclaration.kt
similarity index 69%
rename from idea/testData/codeInsight/outOfBlock/InAntonymsObjectDeclaration.kt
rename to idea/testData/codeInsight/outOfBlock/InAnonymousObjectDeclaration.kt
index d2cf3f01df6..47099eb4498 100644
--- a/idea/testData/codeInsight/outOfBlock/InAntonymsObjectDeclaration.kt
+++ b/idea/testData/codeInsight/outOfBlock/InAnonymousObjectDeclaration.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Unresolved reference: a
val o = object {
fun test() {
diff --git a/idea/testData/codeInsight/outOfBlock/InClass.kt b/idea/testData/codeInsight/outOfBlock/InClass.kt
index a67d257f0a0..ddb7287eb4b 100644
--- a/idea/testData/codeInsight/outOfBlock/InClass.kt
+++ b/idea/testData/codeInsight/outOfBlock/InClass.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Function 'a' without a body must be abstract
class Some {
fun
}
diff --git a/idea/testData/codeInsight/outOfBlock/InClassInUninitializedPropertyAccessor.kt b/idea/testData/codeInsight/outOfBlock/InClassInUninitializedPropertyAccessor.kt
new file mode 100644
index 00000000000..b547373ab71
--- /dev/null
+++ b/idea/testData/codeInsight/outOfBlock/InClassInUninitializedPropertyAccessor.kt
@@ -0,0 +1,11 @@
+// OUT_OF_CODE_BLOCK: FALSE
+// TYPE: '//'
+// ERROR: Property must be initialized
+
+class InClassInUninitializedPropertyAccessor {
+ var prop1: Int
+ set(value) {
+ println("prop.setter")
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt b/idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt
index e0b700fd4a4..cb0d77dc0f6 100644
--- a/idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt
+++ b/idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
class Test {
val more : Int = 0
val test : Int
diff --git a/idea/testData/codeInsight/outOfBlock/InFunInFunctionInitializerInFun.kt b/idea/testData/codeInsight/outOfBlock/InFunInFunctionInitializerInFun.kt
index f4e680fde96..8660ac27f85 100644
--- a/idea/testData/codeInsight/outOfBlock/InFunInFunctionInitializerInFun.kt
+++ b/idea/testData/codeInsight/outOfBlock/InFunInFunctionInitializerInFun.kt
@@ -1,7 +1,8 @@
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Unresolved reference: a
+val b = true
-val a = 1
-fun test() = if (a) {
+fun test() = if (b) {
fun hello() {
}
diff --git a/idea/testData/codeInsight/outOfBlock/InFunInProperty.kt b/idea/testData/codeInsight/outOfBlock/InFunInProperty.kt
index d32e9bf8f95..01e08dd92ca 100644
--- a/idea/testData/codeInsight/outOfBlock/InFunInProperty.kt
+++ b/idea/testData/codeInsight/outOfBlock/InFunInProperty.kt
@@ -1,4 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
+
fun test() {
val some = if () {
fun other() {
diff --git a/idea/testData/codeInsight/outOfBlock/InFunObjectLiteral.kt b/idea/testData/codeInsight/outOfBlock/InFunObjectLiteral.kt
index 14a8c588b5c..2da107ca987 100644
--- a/idea/testData/codeInsight/outOfBlock/InFunObjectLiteral.kt
+++ b/idea/testData/codeInsight/outOfBlock/InFunObjectLiteral.kt
@@ -1,4 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: A type annotation is required on a value parameter
+
interface Some
fun test() {
diff --git a/idea/testData/codeInsight/outOfBlock/InFunctionLiteral.kt b/idea/testData/codeInsight/outOfBlock/InFunctionLiteral.kt
index 1261a146a7d..ab2a9a4f71c 100644
--- a/idea/testData/codeInsight/outOfBlock/InFunctionLiteral.kt
+++ b/idea/testData/codeInsight/outOfBlock/InFunctionLiteral.kt
@@ -1,5 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
-
+// ERROR: Unresolved reference: jq
+// ERROR: Unresolved reference: pria
fun main() {
jq() { pri }
}
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/InGlobalPropertyWithGetter.kt b/idea/testData/codeInsight/outOfBlock/InGlobalPropertyWithGetter.kt
index 68bd74b8610..141c538d3af 100644
--- a/idea/testData/codeInsight/outOfBlock/InGlobalPropertyWithGetter.kt
+++ b/idea/testData/codeInsight/outOfBlock/InGlobalPropertyWithGetter.kt
@@ -1,6 +1,11 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: awhen
+enum class A {
+ e1, e2, e3
+}
class B(val a: A)
+
val B.foo: Int
get() {
return when (a) {
diff --git a/idea/testData/codeInsight/outOfBlock/InLambdaFunction.kt b/idea/testData/codeInsight/outOfBlock/InLambdaFunction.kt
index 4a5c977b7a5..fd3cb89b520 100644
--- a/idea/testData/codeInsight/outOfBlock/InLambdaFunction.kt
+++ b/idea/testData/codeInsight/outOfBlock/InLambdaFunction.kt
@@ -1,9 +1,16 @@
// OUT_OF_CODE_BLOCK: FALSE
+// TYPE: t
+
+fun CharSequence.repeat(n: Int): String {
+ val sb = StringBuilder(n * length)
+ for (i in 1..n) {
+ sb.append(this)
+ }
+ return sb.toString()
+}
fun twice(s: String): String {
val repeatFun: String.(Int) -> String = { t -> this.repeat() }
return repeatFun(s, 2)
}
-
-// TYPE: t
diff --git a/idea/testData/codeInsight/outOfBlock/InMethod.kt b/idea/testData/codeInsight/outOfBlock/InMethod.kt
index 0e29dfaa457..e8a289eec5e 100644
--- a/idea/testData/codeInsight/outOfBlock/InMethod.kt
+++ b/idea/testData/codeInsight/outOfBlock/InMethod.kt
@@ -1,5 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
-
+// ERROR: Unresolved reference: a
+// ERROR: Unsupported [literal prefixes and suffixes]
fun test() {
val a = 1
}
diff --git a/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlock.kt b/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlock.kt
index adc38c1680c..df94064d124 100644
--- a/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlock.kt
+++ b/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlock.kt
@@ -1,5 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
-
+// ERROR: Unresolved reference: a
class Test {
class Other {
fun test() {
diff --git a/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlockExpression.kt b/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlockExpression.kt
index 84656258237..901fbd608f2 100644
--- a/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlockExpression.kt
+++ b/idea/testData/codeInsight/outOfBlock/InNestedClassFunNoTypeBlockExpression.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: This variable must either have a type annotation or be initialized
class Test {
class Other {
diff --git a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorSpecifyType.kt b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorSpecifyType.kt
index 22438436bbb..3340b035c45 100644
--- a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorSpecifyType.kt
+++ b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorSpecifyType.kt
@@ -1,7 +1,10 @@
// OUT_OF_CODE_BLOCK: TRUE
-// TYPE: 'Int`
+// TYPE: 'Int'
class InPropertyAccessorSpecifyType {
val prop1: Int
get(): = 42
-}
\ No newline at end of file
+}
+
+// TODO: Investigate
+// SKIP_ANALYZE_CHECK
diff --git a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithAnnotation.kt b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithAnnotation.kt
index 609b4b43901..bb3df7aa6b9 100644
--- a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithAnnotation.kt
+++ b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithAnnotation.kt
@@ -1,5 +1,7 @@
// OUT_OF_CODE_BLOCK: TRUE
-// TYPE: '@Throws(Exception::class)`
+// TYPE: '@Some("X")'
+
+annotation class Some(val message: String)
class InPropertyAccessorWithAnnotation {
val prop1: Int
diff --git a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInference.kt b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInference.kt
index 73b1f50f8a0..ee48872d016 100644
--- a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInference.kt
+++ b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInference.kt
@@ -1,4 +1,6 @@
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Unresolved reference: a12
+
val test : Int
get() = 12
diff --git a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInferenceInClass.kt b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInferenceInClass.kt
index aa7f35d37db..1aea6c011b8 100644
--- a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInferenceInClass.kt
+++ b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInferenceInClass.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Unresolved reference: foao
class A {
fun foo(): Int = 12
diff --git a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithoutInferenceInClass.kt b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithoutInferenceInClass.kt
index a0698d9c3f9..f2037cc3d67 100644
--- a/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithoutInferenceInClass.kt
+++ b/idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithoutInferenceInClass.kt
@@ -1,5 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
-
+// ERROR: Unresolved reference: foao
class A {
fun foo(): Int = 12
}
diff --git a/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt b/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt
index 06765a8799b..e37be40aa4f 100644
--- a/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt
+++ b/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt
@@ -1,4 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: apri
+
class Test {
val a : () -> Int = { pri }
}
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/InTopFun.kt b/idea/testData/codeInsight/outOfBlock/InTopFun.kt
index 6356c1a1853..75a4e2a2a52 100644
--- a/idea/testData/codeInsight/outOfBlock/InTopFun.kt
+++ b/idea/testData/codeInsight/outOfBlock/InTopFun.kt
@@ -1,2 +1,4 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: printlna
+
fun more() { println }
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/InUninitializedPropertyAccessor.kt b/idea/testData/codeInsight/outOfBlock/InUninitializedPropertyAccessor.kt
new file mode 100644
index 00000000000..a9a3d865f75
--- /dev/null
+++ b/idea/testData/codeInsight/outOfBlock/InUninitializedPropertyAccessor.kt
@@ -0,0 +1,9 @@
+// OUT_OF_CODE_BLOCK: FALSE
+// TYPE: '//'
+// ERROR: Property must be initialized
+
+var prop1: Int
+ set(value) {
+ println("prop.setter")
+ field = value
+ }
\ No newline at end of file
diff --git a/idea/testData/codeInsight/outOfBlock/InitBlock.kt b/idea/testData/codeInsight/outOfBlock/InitBlock.kt
index 457a2335618..faa5393378d 100644
--- a/idea/testData/codeInsight/outOfBlock/InitBlock.kt
+++ b/idea/testData/codeInsight/outOfBlock/InitBlock.kt
@@ -1,5 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
-
+// ERROR: Unresolved reference: caall
class A {
init {
call()
diff --git a/idea/testData/codeInsight/outOfBlock/LocalFunWithBody.kt b/idea/testData/codeInsight/outOfBlock/LocalFunWithBody.kt
index 7fbc5e3ce17..6cfac843d45 100644
--- a/idea/testData/codeInsight/outOfBlock/LocalFunWithBody.kt
+++ b/idea/testData/codeInsight/outOfBlock/LocalFunWithBody.kt
@@ -1,4 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
+
fun test() {
fun hello() {
diff --git a/idea/testData/codeInsight/outOfBlock/LocalFunWithBodyInClass.kt b/idea/testData/codeInsight/outOfBlock/LocalFunWithBodyInClass.kt
index f339634bd5f..516b953a6ed 100644
--- a/idea/testData/codeInsight/outOfBlock/LocalFunWithBodyInClass.kt
+++ b/idea/testData/codeInsight/outOfBlock/LocalFunWithBodyInClass.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
class LocalFunWithBodyInClass {
fun test() {
fun hello() {
diff --git a/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block.kt b/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block.kt
index 1cc62d23bea..6dfc6c3ae89 100644
--- a/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block.kt
+++ b/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block.kt
@@ -1,4 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
+
object Some {
fun test() {
diff --git a/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block_Expression.kt b/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block_Expression.kt
index 6d0facc7b69..960ac46c1d2 100644
--- a/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block_Expression.kt
+++ b/idea/testData/codeInsight/outOfBlock/Object_FunNoType_Block_Expression.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
object Some {
fun test() {
diff --git a/idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt b/idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt
index f11e0089c99..fc12533436b 100644
--- a/idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt
+++ b/idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt
@@ -1,4 +1,5 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
interface Some
diff --git a/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt
index c971827b222..add933ff75a 100644
--- a/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt
+++ b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt
@@ -1,4 +1,7 @@
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: This variable must either have a type annotation or be initialized
+// ERROR: Type mismatch: inferred type is Unit but Int? was expected
+// ERROR: Type mismatch: inferred type is Unit but Int? was expected
val test: Int? = if (true) {
fun test() {
diff --git a/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt
index 0a3f8b0b933..0c898f10435 100644
--- a/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt
+++ b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt
@@ -1,6 +1,8 @@
// OUT_OF_CODE_BLOCK: FALSE
-
// Problem with lazy initialization of nullable properties
+
+// TODO: Investigate
+// --ERROR: Unresolved reference: q
interface Some
val test: Some? = object: Some {
diff --git a/idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt b/idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt
index 48e487bca5e..689b709faa8 100644
--- a/idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt
+++ b/idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt
@@ -1,5 +1,6 @@
// OUT_OF_CODE_BLOCK: TRUE
// SKIP_ANALYZE_CHECK
+// ERROR: Function declaration must have a name
fun test() {
diff --git a/idea/testData/codeInsight/outOfBlock/scriptInLambdaExpression.kts b/idea/testData/codeInsight/outOfBlock/scriptInLambdaExpression.kts
index 9d02de66b74..ad282b03b6b 100644
--- a/idea/testData/codeInsight/outOfBlock/scriptInLambdaExpression.kts
+++ b/idea/testData/codeInsight/outOfBlock/scriptInLambdaExpression.kts
@@ -1,4 +1,7 @@
+// RUNTIME_WITH_SCRIPT_RUNTIME
// OUT_OF_CODE_BLOCK: FALSE
+// ERROR: Unresolved reference: a
+
plugins {
}
diff --git a/idea/testData/codeInsight/outOfBlock/scriptTopLevelCallExpression.kts b/idea/testData/codeInsight/outOfBlock/scriptTopLevelCallExpression.kts
index b6356b5e9e0..b249ef25cdf 100644
--- a/idea/testData/codeInsight/outOfBlock/scriptTopLevelCallExpression.kts
+++ b/idea/testData/codeInsight/outOfBlock/scriptTopLevelCallExpression.kts
@@ -1,5 +1,7 @@
+// RUNTIME_WITH_SCRIPT_RUNTIME
// OUT_OF_CODE_BLOCK: TRUE
-
+// ERROR: Too many arguments for public final fun foo(): Int defined in ScriptTopLevelCallExpression
+// ERROR: Unresolved reference: a
fun foo() = 1
foo()
diff --git a/idea/testData/codeInsight/outOfBlock/scriptTopLevelExpression.kts b/idea/testData/codeInsight/outOfBlock/scriptTopLevelExpression.kts
index e4d0e47834d..97265250241 100644
--- a/idea/testData/codeInsight/outOfBlock/scriptTopLevelExpression.kts
+++ b/idea/testData/codeInsight/outOfBlock/scriptTopLevelExpression.kts
@@ -1,4 +1,8 @@
+// RUNTIME_WITH_SCRIPT_RUNTIME
// OUT_OF_CODE_BLOCK: TRUE
+// ERROR: Unresolved reference: a
+// ERROR: Unsupported [literal prefixes and suffixes]
+
1
// SKIP_ANALYZE_CHECK
diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt
index b964cfa70a5..1acbe766f1c 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt
@@ -13,8 +13,10 @@ import com.intellij.psi.PsiManager
import com.intellij.psi.impl.PsiModificationTrackerImpl
import com.intellij.psi.util.PsiTreeUtil
import junit.framework.TestCase
+import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.trackers.outOfBlockModificationCount
+import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
@@ -39,6 +41,10 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur
TestCase.assertNotNull("Should be valid element", element)
val oobBeforeType = ktFile.outOfBlockModificationCount
val modificationCountBeforeType = tracker.modificationCount
+
+ // have to analyze file before any change to support incremental analysis
+ ktFile.analyzeWithAllCompilerChecks()
+
myFixture.type(stringToType)
PsiDocumentManager.getInstance(myFixture.project).commitDocument(myFixture.getDocument(myFixture.file))
val oobAfterCount = ktFile.outOfBlockModificationCount
@@ -52,11 +58,17 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur
+ FileUtil.loadFile(testDataFile()),
expectedOutOfBlock, oobBeforeType != oobAfterCount
)
+ checkForUnexpectedErrors(ktFile)
+
if (!isSkipCheckDefined) {
checkOOBWithDescriptorsResolve(expectedOutOfBlock)
}
}
+ private fun checkForUnexpectedErrors(ktFile: KtFile) {
+ DirectiveBasedActionUtils.checkForUnexpectedErrors(ktFile) { it.analyzeWithAllCompilerChecks().bindingContext.diagnostics }
+ }
+
private fun checkOOBWithDescriptorsResolve(expectedOutOfBlock: Boolean) {
ApplicationManager.getApplication().runReadAction {
(PsiManager.getInstance(myFixture.project).modificationTracker as PsiModificationTrackerImpl)
diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java
index 6c98680ba96..2c882ade545 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java
@@ -68,9 +68,9 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
runTest("idea/testData/codeInsight/outOfBlock/FunWithType_Initializer_Expression.kt");
}
- @TestMetadata("InAntonymsObjectDeclaration.kt")
- public void testInAntonymsObjectDeclaration() throws Exception {
- runTest("idea/testData/codeInsight/outOfBlock/InAntonymsObjectDeclaration.kt");
+ @TestMetadata("InAnonymousObjectDeclaration.kt")
+ public void testInAnonymousObjectDeclaration() throws Exception {
+ runTest("idea/testData/codeInsight/outOfBlock/InAnonymousObjectDeclaration.kt");
}
@TestMetadata("InClass.kt")
@@ -83,6 +83,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
runTest("idea/testData/codeInsight/outOfBlock/InClassFunctionWithoutInference.kt");
}
+ @TestMetadata("InClassInUninitializedPropertyAccessor.kt")
+ public void testInClassInUninitializedPropertyAccessor() throws Exception {
+ runTest("idea/testData/codeInsight/outOfBlock/InClassInUninitializedPropertyAccessor.kt");
+ }
+
@TestMetadata("InClassPropertyAccessor.kt")
public void testInClassPropertyAccessor() throws Exception {
runTest("idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt");
@@ -218,6 +223,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
runTest("idea/testData/codeInsight/outOfBlock/InTopFun.kt");
}
+ @TestMetadata("InUninitializedPropertyAccessor.kt")
+ public void testInUninitializedPropertyAccessor() throws Exception {
+ runTest("idea/testData/codeInsight/outOfBlock/InUninitializedPropertyAccessor.kt");
+ }
+
@TestMetadata("InitBlock.kt")
public void testInitBlock() throws Exception {
runTest("idea/testData/codeInsight/outOfBlock/InitBlock.kt");