[FIR] Don't report duplicated errors in property declarations

This commit is contained in:
Nick
2020-07-29 13:36:28 +03:00
committed by Mikhail Glukhikh
parent 889324e972
commit 6f85a07290
21 changed files with 58 additions and 52 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ FILE: A.kt
}
FILE: main.kt
public final fun test_1(): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Unresolved name: A> = <Unresolved name: A>#()
lval a: R|ERROR CLASS: Unresolved name: A| = <Unresolved name: A>#()
lval b: R|foo/A| = R|foo/A.A|()
lval c: R|foo/A| = <Unresolved name: A>#()
}
@@ -22,10 +22,10 @@ FILE: typeArgumentsNotAllowed.kt
}
}
public final val a: <ERROR TYPE REF: Unresolved name: MyClass> = Q|rest|.<Unresolved name: MyClass>#
public get(): <ERROR TYPE REF: Unresolved name: MyClass>
public final val b: <ERROR TYPE REF: Unresolved name: MyClass> = Q|rest/Best|.<Unresolved name: MyClass>#
public get(): <ERROR TYPE REF: Unresolved name: MyClass>
public final val a: R|ERROR CLASS: Unresolved name: MyClass| = Q|rest|.<Unresolved name: MyClass>#
public get(): R|ERROR CLASS: Unresolved name: MyClass|
public final val b: R|ERROR CLASS: Unresolved name: MyClass| = Q|rest/Best|.<Unresolved name: MyClass>#
public get(): R|ERROR CLASS: Unresolved name: MyClass|
public final class B<E> : R|kotlin/Any| {
public constructor<E>(): R|rest/B<E>| {
super<R|kotlin/Any|>()
@@ -1,6 +1,6 @@
FILE: main.kt
public final fun test_1(e: R|JavaEnum|): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
lval a: R|ERROR CLASS: Unresolved name: plus| = when (R|<local>/e|) {
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
Int(1)
}
@@ -9,7 +9,7 @@ FILE: main.kt
}
}
.<Unresolved name: plus>#(Int(0))
lval b: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
lval b: R|ERROR CLASS: Unresolved name: plus| = when (R|<local>/e|) {
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
Int(1)
}
@@ -44,7 +44,7 @@ FILE: main.kt
.R|kotlin/Int.plus|(Int(0))
}
public final fun test_2(e: R|JavaEnum?|): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
lval a: R|ERROR CLASS: Unresolved name: plus| = when (R|<local>/e|) {
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
Int(1)
}
@@ -77,7 +77,7 @@ FILE: exhaustiveness_sealedSubClass.kt
.R|kotlin/Int.plus|(Int(0))
}
public final fun test_2(e: R|A|): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
lval a: R|ERROR CLASS: Unresolved name: plus| = when (R|<local>/e|) {
($subj$ is R|D|) -> {
Int(1)
}
@@ -86,7 +86,7 @@ FILE: exhaustiveness_sealedSubClass.kt
}
}
.<Unresolved name: plus>#(Int(0))
lval b: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
lval b: R|ERROR CLASS: Unresolved name: plus| = when (R|<local>/e|) {
($subj$ is R|B|) -> {
Int(1)
}
@@ -98,7 +98,7 @@ FILE: exhaustiveness_sealedSubClass.kt
}
}
.<Unresolved name: plus>#(Int(0))
lval c: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
lval c: R|ERROR CLASS: Unresolved name: plus| = when (R|<local>/e|) {
($subj$ is R|B|) -> {
Int(1)
}
@@ -107,7 +107,7 @@ FILE: exhaustiveness_sealedSubClass.kt
}
}
.<Unresolved name: plus>#(Int(0))
lval d: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
lval d: R|ERROR CLASS: Unresolved name: plus| = when (R|<local>/e|) {
($subj$ is R|C|) -> {
Int(1)
}
@@ -29,8 +29,8 @@ FILE: CallBasedInExpressionGenerator.kt
public final val codegen: R|org/jetbrains/kotlin/codegen/range/inExpression/ExpressionCodegen| = R|<local>/codegen|
public get(): R|org/jetbrains/kotlin/codegen/range/inExpression/ExpressionCodegen|
private final val resolvedCall: <ERROR TYPE REF: Unresolved name: getResolvedCallWithAssert> = R|<local>/operatorReference|.<Unresolved name: getResolvedCallWithAssert>#(R|<local>/codegen|.<Unresolved name: bindingContext>#)
private get(): <ERROR TYPE REF: Unresolved name: getResolvedCallWithAssert>
private final val resolvedCall: R|ERROR CLASS: Unresolved name: getResolvedCallWithAssert| = R|<local>/operatorReference|.<Unresolved name: getResolvedCallWithAssert>#(R|<local>/codegen|.<Unresolved name: bindingContext>#)
private get(): R|ERROR CLASS: Unresolved name: getResolvedCallWithAssert|
private final val isInverted: R|kotlin/Boolean| = ==(R|<local>/operatorReference|.<Unresolved name: getReferencedNameElementType>#(), <Unresolved name: KtTokens>#.<Unresolved name: NOT_IN>#)
private get(): R|kotlin/Boolean|
@@ -75,7 +75,7 @@ FILE: CallBasedInExpressionGenerator.kt
}
private final fun invokeFunction(v: R|org/jetbrains/kotlin/codegen/range/inExpression/InstructionAdapter|): R|kotlin/Unit| {
lval result: <ERROR TYPE REF: Unresolved name: invokeFunction> = this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.codegen|.<Unresolved name: invokeFunction>#(this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|.<Unresolved name: call>#, this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|, <Unresolved name: none>#())
lval result: R|ERROR CLASS: Unresolved name: invokeFunction| = this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.codegen|.<Unresolved name: invokeFunction>#(this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|.<Unresolved name: call>#, this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|, <Unresolved name: none>#())
R|<local>/result|.<Unresolved name: put>#(R|<local>/result|.<Unresolved name: type>#, R|<local>/result|.<Unresolved name: kotlinType>#, R|<local>/v|)
}
@@ -57,7 +57,7 @@ FILE: access.kt
lval a: R|kotlin/Int| = Int(10)
lval b: R|kotlin/Int| = R|<local>/a|
lval d: R|kotlin/String| = String()
lval c: <ERROR TYPE REF: Unresolved name: c> = <Unresolved name: c>#
lval c: R|ERROR CLASS: Unresolved name: c| = <Unresolved name: c>#
<Unresolved name: abc>#()
local final fun bcd(): R|kotlin/Unit| {
}
@@ -29,7 +29,7 @@ FILE: Test.kt
lval bbd: R|BB.D| = Q|BB.D|
lval aac: R|AA.C| = Q|AA.C|
Q|JavaClass|.R|/JavaClass.bar|()
lval errC: <ERROR TYPE REF: Unresolved name: C> = Q|BB|.<Unresolved name: C>#
lval errBarViaBB: <ERROR TYPE REF: Unresolved name: bar> = Q|BB|.<Unresolved name: bar>#()
lval errBarViaAA: <ERROR TYPE REF: Unresolved name: bar> = Q|AA|.<Unresolved name: bar>#()
lval errC: R|ERROR CLASS: Unresolved name: C| = Q|BB|.<Unresolved name: C>#
lval errBarViaBB: R|ERROR CLASS: Unresolved name: bar| = Q|BB|.<Unresolved name: bar>#()
lval errBarViaAA: R|ERROR CLASS: Unresolved name: bar| = Q|AA|.<Unresolved name: bar>#()
}
@@ -47,5 +47,5 @@ FILE: companion.kt
Q|B|.R|/B.Companion.baz|()
lval x: R|kotlin/String| = Q|A|.R|/A.Companion.D|
lval y: R|kotlin/String| = Q|B|.R|/B.Companion.C|
lval z: <ERROR TYPE REF: Unresolved name: D> = Q|B|.<Unresolved name: D>#
lval z: R|ERROR CLASS: Unresolved name: D| = Q|B|.<Unresolved name: D>#
}
@@ -40,5 +40,5 @@ FILE: localObjects.kt
Q|B|.R|/B.foo|()
}
public final val bb: <ERROR TYPE REF: Unresolved name: foo> = <Unresolved name: B>#.<Unresolved name: foo>#()
public get(): <ERROR TYPE REF: Unresolved name: foo>
public final val bb: R|ERROR CLASS: Unresolved name: foo| = <Unresolved name: B>#.<Unresolved name: foo>#()
public get(): R|ERROR CLASS: Unresolved name: foo|
@@ -25,7 +25,7 @@ FILE: nestedObjects.kt
}
}
public final val err: <ERROR TYPE REF: Unresolved name: B> = Q|B|.<Unresolved name: A>#.<Unresolved name: B>#
public get(): <ERROR TYPE REF: Unresolved name: B>
public final val err: R|ERROR CLASS: Unresolved name: B| = Q|B|.<Unresolved name: A>#.<Unresolved name: B>#
public get(): R|ERROR CLASS: Unresolved name: B|
public final val correct: R|A.B.A| = Q|A.B.A|
public get(): R|A.B.A|
@@ -41,7 +41,7 @@ FILE: inner.kt
public final fun test(): R|kotlin/Unit| {
lval o: R|Owner| = R|/Owner.Owner|()
R|<local>/o|.R|/Owner.foo|()
lval err: <ERROR TYPE REF: Unresolved name: Inner> = Q|Owner|.<Unresolved name: Inner>#()
lval err: R|ERROR CLASS: Unresolved name: Inner| = Q|Owner|.<Unresolved name: Inner>#()
R|<local>/err|.<Unresolved name: baz>#()
lval i: R|Owner.Inner| = R|<local>/o|.R|/Owner.Inner.Inner|()
R|<local>/i|.R|/Owner.Inner.gau|()
@@ -35,7 +35,7 @@ FILE: nestedClassContructor.kt
public final fun foo(): R|kotlin/Unit| {
lval a: R|A| = R|/A.A|()
lval ac: R|A.C| = Q|A|.R|/A.C.C|()
lval c: <ERROR TYPE REF: Unresolved name: C> = <Unresolved name: C>#()
lval c: R|ERROR CLASS: Unresolved name: C| = <Unresolved name: C>#()
}
}
@@ -1,5 +1,5 @@
FILE: main.kt
public final fun test(): R|kotlin/Unit| {
lval some: R|Some| = R|/Some.Some|()
lval another: <ERROR TYPE REF: Unresolved name: Another> = <Unresolved name: Another>#()
lval another: R|ERROR CLASS: Unresolved name: Another| = <Unresolved name: Another>#()
}
@@ -1,15 +1,15 @@
FILE: main.kt
public final fun test_1(x: R|A|): R|kotlin/Unit| {
lval str1: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/x|.R|/A.vmParameters|
lval str2: <ERROR TYPE REF: Unresolved name: vMParameters> = R|<local>/x|.<Unresolved name: vMParameters>#
lval str2: R|ERROR CLASS: Unresolved name: vMParameters| = R|<local>/x|.<Unresolved name: vMParameters>#
}
public final fun test_2(x: R|B|): R|kotlin/Unit| {
lval int: R|ft<kotlin/Int, kotlin/Int?>!| = R|<local>/x|.R|/B.vmParameters|
lval error: <ERROR TYPE REF: Unresolved name: vMParameters> = R|<local>/x|.<Unresolved name: vMParameters>#
lval error: R|ERROR CLASS: Unresolved name: vMParameters| = R|<local>/x|.<Unresolved name: vMParameters>#
}
public final fun test_3(x: R|C|): R|kotlin/Unit| {
lval error: <ERROR TYPE REF: Ambiguity: vmParameters, [/C.vmParameters, /C.vmParameters]> = R|<local>/x|.<Ambiguity: vmParameters, [/C.vmParameters, /C.vmParameters]>#
lval int: <ERROR TYPE REF: Unresolved name: vMParameters> = R|<local>/x|.<Unresolved name: vMParameters>#
lval error: R|ERROR CLASS: Ambiguity: vmParameters, [/C.vmParameters, /C.vmParameters]| = R|<local>/x|.<Ambiguity: vmParameters, [/C.vmParameters, /C.vmParameters]>#
lval int: R|ERROR CLASS: Unresolved name: vMParameters| = R|<local>/x|.<Unresolved name: vMParameters>#
}
public final class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
@@ -12,10 +12,7 @@ import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticFactory0
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
import org.jetbrains.kotlin.fir.declarations.FirProperty
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
import org.jetbrains.kotlin.fir.diagnostics.*
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind.*
@@ -39,16 +36,7 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
// It always uses the same type ref as the corresponding property
return
}
is FirConstructor -> if (lastContainingDeclaration.source?.kind is FirFakeSourceElementKind) {
// Implicit primary constructor uses the same type ref as the corresponding property
return
}
is FirValueParameter -> if (lastContainingDeclaration.source?.kind is FirFakeSourceElementKind) {
// Value parameter of default setter uses the same type ref as the corresponding property
return
}
is FirProperty -> if (lastContainingDeclaration.source?.kind is FirFakeSourceElementKind) {
// Properties of implicit primary constructor uses the same type ref as the corresponding value parameter
else -> if (lastContainingDeclaration?.source?.kind is FirFakeSourceElementKind) {
return
}
}
@@ -867,7 +867,15 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
is FirImplicitTypeRef -> buildErrorTypeRef {
diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError)
}
else -> resultType
else -> {
buildResolvedTypeRef {
type = resultType.coneType
annotations.addAll(resultType.annotations)
resultType.source.psi?.let {
source = FirFakeSourceElement(it, FirFakeSourceElementKind.PropertyFromParameter)
}
}
}
}
variable.transformReturnTypeRef(
transformer,
@@ -879,7 +887,17 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
is FirImplicitTypeRef -> buildErrorTypeRef {
diagnostic = ConeSimpleDiagnostic("No result type for getter", DiagnosticKind.InferenceError)
}
else -> resultType
else -> {
resultType?.let {
buildResolvedTypeRef {
type = resultType.coneType
annotations.addAll(resultType.annotations)
resultType.source.psi?.let {
source = FirFakeSourceElement(it, FirFakeSourceElementKind.PropertyFromParameter)
}
}
}
}
}
variable.transformReturnTypeRef(
transformer,
@@ -1,6 +1,6 @@
class P
fun foo(p: P): Any {
val v = p as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>
val v = p as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>
return v
}
@@ -20,7 +20,7 @@ val x = object<T, K: Comparable<K>> {
fun case_4() {
val x = object<T> {
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!>
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!>
}
val y = x.test() // type y is T
@@ -20,7 +20,7 @@ val x = object<T, K: Comparable<K>> {
fun case_4() {
val x = object<T> {
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!>
fun test() = 10 as <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>T<!>
}
val y = x.test() // type y is T
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
data class A(val i: Int, val j: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>)
data class B(val i: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>, val j: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>)
data class A(val i: Int, val j: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>)
data class B(val i: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>, val j: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>G<!>)
fun fa(a: A) {
@@ -14,6 +14,6 @@ fun test() {
}
fun <T> bar() {
val typeParameter_as_val = <!OTHER_ERROR, OTHER_ERROR!>T<!>
val typeParameter_as_val = <!OTHER_ERROR!>T<!>
val typeParameter_as_fun = <!UNRESOLVED_REFERENCE!>T<!>()
}