FIR checker: skip error named reference if receiver is unresolved
Currently, FIR reports errors caused by previous resolution failure. For example with unresolved `a` and `b` in code `a.b`, both `a` and `b` are highlighted. FE1.0 only highlights `a` since it's the root cause. This change applies this heuristics when reporting FirDiagnostics.
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
d6907222cd
commit
fb14b03824
Vendored
+3
-3
@@ -15,13 +15,13 @@ class CallBasedInExpressionGenerator(
|
||||
operatorReference: KtSimpleNameExpression
|
||||
) : InExpressionGenerator {
|
||||
private val resolvedCall = operatorReference.<!UNRESOLVED_REFERENCE!>getResolvedCallWithAssert<!>(codegen.<!UNRESOLVED_REFERENCE!>bindingContext<!>)
|
||||
private val isInverted = operatorReference.<!UNRESOLVED_REFERENCE!>getReferencedNameElementType<!>() == <!UNRESOLVED_REFERENCE!>KtTokens<!>.<!UNRESOLVED_REFERENCE!>NOT_IN<!>
|
||||
private val isInverted = operatorReference.<!UNRESOLVED_REFERENCE!>getReferencedNameElementType<!>() == <!UNRESOLVED_REFERENCE!>KtTokens<!>.NOT_IN
|
||||
|
||||
override fun generate(argument: StackValue): BranchedValue =
|
||||
gen(argument).let { if (isInverted) <!UNRESOLVED_REFERENCE!>Invert<!>(it) else it }
|
||||
|
||||
private fun gen(argument: StackValue): BranchedValue =
|
||||
object : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>BranchedValue<!>(argument, null, argument.<!UNRESOLVED_REFERENCE!>type<!>, <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!>)<!> {
|
||||
object : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>BranchedValue<!>(argument, null, argument.<!UNRESOLVED_REFERENCE!>type<!>, <!UNRESOLVED_REFERENCE!>Opcodes<!>.IFEQ)<!> {
|
||||
override fun putSelector(type: Type, kotlinType: KotlinType?, v: InstructionAdapter) {
|
||||
invokeFunction(v)
|
||||
<!UNRESOLVED_REFERENCE!>coerceTo<!>(type, kotlinType, v)
|
||||
@@ -29,7 +29,7 @@ class CallBasedInExpressionGenerator(
|
||||
|
||||
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
||||
invokeFunction(v)
|
||||
v.<!UNRESOLVED_REFERENCE!>visitJumpInsn<!>(if (jumpIfFalse) <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!> else <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFNE<!>, jumpLabel)
|
||||
v.<!UNRESOLVED_REFERENCE!>visitJumpInsn<!>(if (jumpIfFalse) <!UNRESOLVED_REFERENCE!>Opcodes<!>.IFEQ else <!UNRESOLVED_REFERENCE!>Opcodes<!>.IFNE, jumpLabel)
|
||||
}
|
||||
|
||||
private fun invokeFunction(v: InstructionAdapter) {
|
||||
|
||||
@@ -18,4 +18,4 @@ fun test() {
|
||||
B.foo()
|
||||
}
|
||||
|
||||
val bb = <!UNRESOLVED_REFERENCE!>B<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
val bb = <!UNRESOLVED_REFERENCE!>B<!>.foo()
|
||||
|
||||
@@ -6,5 +6,5 @@ object A {
|
||||
|
||||
object B
|
||||
|
||||
val err = B.<!UNRESOLVED_REFERENCE!>A<!>.<!UNRESOLVED_REFERENCE!>B<!>
|
||||
val err = B.<!UNRESOLVED_REFERENCE!>A<!>.B
|
||||
val correct = A.B.A
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ fun main() {
|
||||
x <!UNRESOLVED_REFERENCE!>><!> 1
|
||||
}
|
||||
|
||||
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo<!>({ <!UNRESOLVED_REFERENCE!>it<!> <!UNRESOLVED_REFERENCE!>><!> 1 })
|
||||
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo<!>({ <!UNRESOLVED_REFERENCE!>it<!> > 1 })
|
||||
|
||||
val x = { x: Int -> x > 1 }
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ fun test_5(a: A, in1: In1<A>, in2: In1<in A>, in3: In1<out A>) {
|
||||
|
||||
fun test_6(a: A, out1: Out1<A>, out2: Out1<in A>, out3: Out1<out A>) {
|
||||
out1.value().foo()
|
||||
out2.<!UNRESOLVED_REFERENCE!>value<!>().<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
out2.<!UNRESOLVED_REFERENCE!>value<!>().foo()
|
||||
out3.value().foo()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user