Drop wrong assertion about duplicating properties in data class

#EA-64269 Fixed
This commit is contained in:
Denis Zharkov
2015-06-01 18:33:33 +03:00
parent 70dbbd8fda
commit 349d5f02ea
4 changed files with 57 additions and 4 deletions
@@ -134,8 +134,7 @@ public open class LazyClassMemberScope(
private fun generateDataClassMethods(result: MutableCollection<FunctionDescriptor>, name: Name) {
if (!KotlinBuiltIns.isData(thisDescriptor)) return
val constructor = getPrimaryConstructor()
if (constructor == null) return
val constructor = getPrimaryConstructor() ?: return
val primaryConstructorParameters = declarationProvider.getOwnerInfo().getPrimaryConstructorParameters()
assert(constructor.getValueParameters().size() == primaryConstructorParameters.size()) { "From descriptor: " + constructor.getValueParameters().size() + " but from PSI: " + primaryConstructorParameters.size() }
@@ -150,8 +149,6 @@ public open class LazyClassMemberScope(
val properties = getProperties(parameter.getName())
if (properties.isEmpty()) continue
assert(properties.size() == 1) { "A constructor parameter is resolved to more than one (" + properties.size() + ") property: " + parameter }
val property = properties.iterator().next() as PropertyDescriptor
++componentIndex
@@ -0,0 +1,9 @@
data class A1(val <!REDECLARATION, REDECLARATION, REDECLARATION!>x<!>: Int, val y: String, val <!REDECLARATION, REDECLARATION, REDECLARATION!>x<!>: Int) {
val z = ""
}
data class A2(val <!REDECLARATION!>x<!>: Int, val y: String) {
val <!REDECLARATION!>x<!> = ""
}
data class A3(<!REDECLARATION, REDECLARATION, REDECLARATION!>val<!SYNTAX!><!> :Int<!>, <!REDECLARATION, REDECLARATION, REDECLARATION!>val<!SYNTAX!><!> : Int<!>)
@@ -0,0 +1,41 @@
package
kotlin.data() internal final class A1 {
public constructor A1(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String, /*2*/ x: kotlin.Int)
internal final val x: kotlin.Int
internal final val x: kotlin.Int
internal final val y: kotlin.String
internal final val z: kotlin.String = ""
internal final /*synthesized*/ fun component1(): kotlin.Int
internal final /*synthesized*/ fun component2(): kotlin.String
internal final /*synthesized*/ fun component3(): kotlin.Int
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ..., /*2*/ x: kotlin.Int = ...): A1
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
kotlin.data() internal final class A2 {
public constructor A2(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String)
internal final val x: kotlin.Int
internal final val x: kotlin.String = ""
internal final val y: kotlin.String
internal final /*synthesized*/ fun component1(): kotlin.String
internal final /*synthesized*/ fun component2(): kotlin.String
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ...): A2
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
kotlin.data() internal final class A3 {
public constructor A3(/*0*/ <no name provided>: kotlin.Int, /*1*/ <no name provided>: kotlin.Int)
internal final val <no name provided>: kotlin.Int
internal final val <no name provided>: kotlin.Int
internal final /*synthesized*/ fun component1(): kotlin.Int
internal final /*synthesized*/ fun component2(): kotlin.Int
public final /*synthesized*/ fun copy(/*0*/ <no name provided>: kotlin.Int = ..., /*1*/ <no name provided>: kotlin.Int = ...): A3
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -2844,6 +2844,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("repeatedProperties.kt")
public void testRepeatedProperties() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.kt");
doTest(fileName);
}
@TestMetadata("secondParamIsVal.kt")
public void testSecondParamIsVal() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt");