diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt index b340c1c70bc..b01cd3d520b 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt @@ -57,6 +57,8 @@ abstract class LexicalScopeStorage( val name = descriptor.name val descriptorIndex = addDescriptor(descriptor) + if (name.isSpecial) return + if (variablesAndClassifiersByName == null) { variablesAndClassifiersByName = HashMap() } diff --git a/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.kt b/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.kt index 75cc614787b..5713d718dcf 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.kt @@ -6,4 +6,4 @@ data class A2(val x: Int, val y: String) { val x = "" } -data class A3(val :Int, val : Int) +data class A3(val :Int, val : Int) diff --git a/compiler/testData/diagnostics/tests/regressions/ea66984.kt b/compiler/testData/diagnostics/tests/regressions/ea66984.kt index f7c697ccb04..226ca424ab1 100644 --- a/compiler/testData/diagnostics/tests/regressions/ea66984.kt +++ b/compiler/testData/diagnostics/tests/regressions/ea66984.kt @@ -1,2 +1,2 @@ // !DIAGNOSTICS: -NO_VALUE_FOR_PARAMETER -class Tree<T>(T element, Tree left, Tree right) {} \ No newline at end of file +class Tree<T>(T element, Tree left, Tree right) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt b/compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt new file mode 100644 index 00000000000..51e32baee57 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt @@ -0,0 +1,10 @@ +data class XY(val x: Int, val y: Int) + +fun foo(list: List) { + for ((x1, y1) in list) { + for ((x2, y2) in list) { + if (x1 == y2 && x2 == y1) return + } + list.map { (x3, y3) -> x3 + y3 } + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.txt b/compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.txt new file mode 100644 index 00000000000..d7cdc1e75ee --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.txt @@ -0,0 +1,15 @@ +package + +public fun foo(/*0*/ list: kotlin.collections.List): kotlin.Unit + +public final data class XY { + public constructor XY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + public final val x: kotlin.Int + public final val y: kotlin.Int + public final operator /*synthesized*/ fun component1(): kotlin.Int + public final operator /*synthesized*/ fun component2(): kotlin.Int + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ...): XY + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index ee81f30d747..b0929f3be95 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -161,6 +161,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW doTest(fileName); } + @TestMetadata("shadowingInDestructuring.kt") + public void testShadowingInDestructuring() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)