Skip to content

Commit 5199c87

Browse files
committed
fix(mps-model-adapters): fix incompatibility with MPS 2021.2
1 parent 41bbb72 commit 5199c87

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.modelix.model.mpsadapters;
18+
19+
import org.jetbrains.mps.openapi.language.SAbstractConcept;
20+
import org.jetbrains.mps.openapi.language.SConcept;
21+
import org.jetbrains.mps.openapi.language.SInterfaceConcept;
22+
23+
/**
24+
* The Kotlin compiler cannot disambiguate the call to getSuperConcept/getSuperInterfaces
25+
* that where moved to SAbstractConcept in MPS 2021.2, but still exist in SConcept/SInterfaceConcept.
26+
*/
27+
public class ConceptWorkaround {
28+
public SAbstractConcept concept;
29+
30+
public ConceptWorkaround(SAbstractConcept concept) {
31+
this.concept = concept;
32+
}
33+
34+
public SConcept getSuperConcept() {
35+
return ((SConcept) concept).getSuperConcept();
36+
}
37+
38+
public Iterable<SInterfaceConcept> getSuperInterfaces() {
39+
if (concept instanceof SConcept) {
40+
return ((SConcept) concept).getSuperInterfaces();
41+
} else {
42+
return ((SInterfaceConcept) concept).getSuperInterfaces();
43+
}
44+
}
45+
}

mps-model-adapters/src/main/kotlin/org/modelix/model/mpsadapters/MPSConcept.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ data class MPSConcept(val concept: SAbstractConceptAdapter) : IConcept {
6565

6666
override fun getDirectSuperConcepts(): List<IConcept> {
6767
return when (concept) {
68-
is SConcept -> listOfNotNull<SAbstractConcept>(concept.superConcept) + concept.superInterfaces
69-
is SInterfaceConcept -> concept.superInterfaces
70-
else -> emptyList()
68+
is SConcept -> listOfNotNull<SAbstractConcept>(ConceptWorkaround(concept).superConcept) +
69+
ConceptWorkaround(concept).superInterfaces
70+
is SInterfaceConcept -> ConceptWorkaround(concept).superInterfaces
71+
else -> emptyList<SAbstractConcept>()
7172
}.map { MPSConcept(it) }
7273
}
7374

0 commit comments

Comments
 (0)