Skip to content

Commit e8bce98

Browse files
committed
Check if classes with conflicting properties are related
(Then they are actually not conflicting in this case)
1 parent 3181184 commit e8bce98

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

model-lowerings-common/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dependencies {
66
implementation(project(":ast-common"))
77
implementation(project(":ast-model"))
88
implementation(project(":graphs"))
9+
implementation(project(":itertools"))
910
implementation(project(":logging"))
1011
implementation(project(":ownerContext"))
1112
implementation(project(":panic"))

model-lowerings-common/src/org/jetbrains/dukat/model/commonLowerings/overrides/VarConflictResolveLowering.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jetbrains.dukat.model.commonLowerings.overrides
22

3+
import cartesian
34
import org.jetbrains.dukat.astCommon.IdentifierEntity
45
import org.jetbrains.dukat.astCommon.NameEntity
56
import org.jetbrains.dukat.astCommon.appendLeft
@@ -20,7 +21,6 @@ import org.jetbrains.dukat.model.commonLowerings.OverrideTypeChecker
2021
import org.jetbrains.dukat.model.commonLowerings.allParentMembers
2122
import org.jetbrains.dukat.model.commonLowerings.buildInheritanceGraph
2223
import org.jetbrains.dukat.ownerContext.NodeOwner
23-
import org.jetbrains.dukat.ownerContext.wrap
2424

2525
private fun PropertyModel.toVal(): PropertyModel {
2626
return copy(
@@ -42,10 +42,10 @@ private class VarOverrideResolver(
4242
): List<List<MemberData>> {
4343
return parentMembers.keys.mapNotNull { name ->
4444
val properties = parentMembers[name].orEmpty().filter { it.memberModel is PropertyModel }
45-
if (properties.isEmpty() || properties.all {
45+
if (properties.isEmpty() || cartesian(properties, properties).all { (first, second) ->
4646
with(typeChecker) {
47-
(it.memberModel as PropertyModel).type.isEquivalent((properties[0].memberModel as PropertyModel).type)
48-
}
47+
(first.memberModel as PropertyModel).type.isEquivalent((second.memberModel as PropertyModel).type)
48+
} || inheritanceContext.areRelated(first.ownerModel, second.ownerModel)
4949
}) {
5050
null
5151
} else {

0 commit comments

Comments
 (0)