Extract diagnostics about references to variables to a separate one
Note that I've left in FIR everything as is to avoid non-trivial refactoring that is required right now to report more specific diagnostics ^KT-59152
This commit is contained in:
committed by
Space Team
parent
9cf40f8c2f
commit
1153238fd7
@@ -81,6 +81,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_WHEN = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_WHEN = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_FUN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_FUN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> UNSUPPORTED_SUSPEND_TEST = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> UNSUPPORTED_SUSPEND_TEST = DiagnosticFactory0.create(ERROR);
|
||||||
|
DiagnosticFactory0<PsiElement> UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
+1
@@ -829,6 +829,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(UNSUPPORTED_SEALED_WHEN, "'sealed' in front of 'when' is reserved");
|
MAP.put(UNSUPPORTED_SEALED_WHEN, "'sealed' in front of 'when' is reserved");
|
||||||
MAP.put(UNSUPPORTED_SEALED_FUN_INTERFACE, "'sealed fun interface' is unsupported");
|
MAP.put(UNSUPPORTED_SEALED_FUN_INTERFACE, "'sealed fun interface' is unsupported");
|
||||||
MAP.put(UNSUPPORTED_SUSPEND_TEST, "'suspend' functions annotated with @kotlin.test.Test are unsupported");
|
MAP.put(UNSUPPORTED_SUSPEND_TEST, "'suspend' functions annotated with @kotlin.test.Test are unsupported");
|
||||||
|
MAP.put(UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS, "References to variables and parameters are unsupported");
|
||||||
|
|
||||||
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
|
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
|
||||||
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
|
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
|
||||||
|
|||||||
+1
-1
@@ -614,7 +614,7 @@ class DoubleColonExpressionResolver(
|
|||||||
trace.report(EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED.on(simpleName, descriptor))
|
trace.report(EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED.on(simpleName, descriptor))
|
||||||
}
|
}
|
||||||
if (descriptor is VariableDescriptor && descriptor !is PropertyDescriptor) {
|
if (descriptor is VariableDescriptor && descriptor !is PropertyDescriptor) {
|
||||||
trace.report(UNSUPPORTED.on(simpleName, "References to variables aren't supported yet"))
|
trace.report(UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS.on(simpleName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||||
|
|
||||||
|
val i: Int = 10
|
||||||
|
get() {
|
||||||
|
::<!UNSUPPORTED!>field<!>
|
||||||
|
return field
|
||||||
|
}
|
||||||
+1
-2
@@ -1,8 +1,7 @@
|
|||||||
// FIR_IDENTICAL
|
|
||||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||||
|
|
||||||
val i: Int = 10
|
val i: Int = 10
|
||||||
get() {
|
get() {
|
||||||
::<!UNSUPPORTED!>field<!>
|
::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>field<!>
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
fun a() {
|
fun a() {
|
||||||
val x = 10
|
val x = 10
|
||||||
foo(::<!UNSUPPORTED!>x<!>)
|
foo(::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo(a: Any) {}
|
fun foo(a: Any) {}
|
||||||
|
|
||||||
fun test1(test2: () -> Unit = ::test2) {} // Resolve to function
|
fun test1(test2: () -> Unit = ::test2) {} // Resolve to function
|
||||||
private fun test2() {}
|
private fun test2() {}
|
||||||
fun test3(test4: () -> Unit = ::<!UNSUPPORTED!>test4<!>) {}
|
fun test3(test4: () -> Unit = ::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>test4<!>) {}
|
||||||
|
|
||||||
fun test5(test6: (test: Test) -> Unit = Test::helper) {
|
fun test5(test6: (test: Test) -> Unit = Test::helper) {
|
||||||
test6(Test())
|
test6(Test())
|
||||||
|
|||||||
+4
-4
@@ -3,13 +3,13 @@
|
|||||||
fun eat(value: Any) {}
|
fun eat(value: Any) {}
|
||||||
|
|
||||||
fun test(param: String) {
|
fun test(param: String) {
|
||||||
val a = ::<!UNSUPPORTED!>param<!>
|
val a = ::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>param<!>
|
||||||
|
|
||||||
val local = "local"
|
val local = "local"
|
||||||
val b = ::<!UNSUPPORTED!>local<!>
|
val b = ::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>local<!>
|
||||||
|
|
||||||
val lambda = { -> }
|
val lambda = { -> }
|
||||||
val g = ::<!UNSUPPORTED!>lambda<!>
|
val g = ::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>lambda<!>
|
||||||
|
|
||||||
eat(::<!UNSUPPORTED!>param<!>)
|
eat(::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>param<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -9,6 +9,6 @@ class Foo {
|
|||||||
fun main() {
|
fun main() {
|
||||||
val f = Foo()
|
val f = Foo()
|
||||||
val a: Int
|
val a: Int
|
||||||
<!UNRESOLVED_REFERENCE!>get<!>() = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix
|
<!UNRESOLVED_REFERENCE!>get<!>() = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>a<!>) // no exception after fix
|
||||||
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
|
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
|
||||||
}
|
}
|
||||||
Vendored
+1
-1
@@ -9,6 +9,6 @@ class Foo {
|
|||||||
fun main(x: Int) {
|
fun main(x: Int) {
|
||||||
val f = Foo()
|
val f = Foo()
|
||||||
val a: Int
|
val a: Int
|
||||||
<!UNRESOLVED_REFERENCE!>get<!>() = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix
|
<!UNRESOLVED_REFERENCE!>get<!>() = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS!>x<!>) // no exception after fix
|
||||||
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
|
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,6 +3,6 @@
|
|||||||
internal class Z<K> {
|
internal class Z<K> {
|
||||||
val map = HashMap<String, String>()
|
val map = HashMap<String, String>()
|
||||||
inline fun compute(key: String, producer: () -> String): String {
|
inline fun compute(key: String, producer: () -> String): String {
|
||||||
return map.getOrPut(key, ::<!UNSUPPORTED, USAGE_IS_NOT_INLINABLE!>producer<!>)
|
return map.getOrPut(key, ::<!UNSUPPORTED_REFERENCES_TO_VARIABLES_AND_PARAMETERS, USAGE_IS_NOT_INLINABLE!>producer<!>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user