Skip to content

Commit

Permalink
[lang] Do not check inheritance in the jvm model inferrer.
Browse files Browse the repository at this point in the history
close #524

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Oct 28, 2016
1 parent bc8fc3b commit 3e664fb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 70 deletions.
Expand Up @@ -157,7 +157,6 @@
import io.sarl.lang.sarl.SarlSkill;
import io.sarl.lang.sarl.SarlSpace;
import io.sarl.lang.services.SARLGrammarKeywordAccess;
import io.sarl.lang.typesystem.InheritanceHelper;
import io.sarl.lang.typesystem.SARLAnnotationUtil;
import io.sarl.lang.typesystem.SARLExpressionHelper;
import io.sarl.lang.typesystem.SARLReentrantTypeResolver;
Expand Down Expand Up @@ -286,9 +285,6 @@ public class SARLJvmModelInferrer extends XtendJvmModelInferrer {
@Inject
private IInlineExpressionCompiler inlineExpressionCompiler;

@Inject
private InheritanceHelper inheritanceHelper;

/** Generation contexts.
*/
private LinkedList<GenerationContext> bufferedContexes = new LinkedList<>();
Expand Down Expand Up @@ -1681,7 +1677,7 @@ protected void transform(SarlCapacityUses source, JvmGenericType container) {
for (final JvmTypeReference capacityType : source.getCapacities()) {
final JvmType type = capacityType.getType();
if (type instanceof JvmGenericType
&& this.inheritanceHelper.isSubTypeOf(capacityType, Capacity.class, SarlCapacity.class)
/*&& this.inheritanceHelper.isSubTypeOf(capacityType, Capacity.class, SarlCapacity.class)*/
&& !context.getGeneratedCapacityUseFields().contains(capacityType.getIdentifier())) {
// Generate the extension field
final String fieldName = Utils.createNameForHiddenCapacityImplementationAttribute(capacityType.getIdentifier());
Expand Down Expand Up @@ -2081,12 +2077,11 @@ protected void appendConstrainedExtends(
GenerationContext context,
JvmGenericType owner, Class<?> defaultJvmType, Class<? extends XtendTypeDeclaration> defaultSarlType,
List<? extends JvmParameterizedTypeReference> supertypes) {
final boolean isInterface = owner.isInterface();
boolean explicitType = false;
for (final JvmParameterizedTypeReference superType : supertypes) {
if (!Objects.equal(owner.getIdentifier(), superType.getIdentifier())
&& superType.getType() instanceof JvmGenericType
&& this.inheritanceHelper.isProxyOrSubTypeOf(superType, defaultJvmType, defaultSarlType, isInterface)) {
/*&& this.inheritanceHelper.isProxyOrSubTypeOf(superType, defaultJvmType, defaultSarlType, isInterface)*/) {
owner.getSuperTypes().add(this.typeBuilder.cloneWithProxies(superType));
context.incrementSerial(superType.getIdentifier().hashCode());
explicitType = true;
Expand Down Expand Up @@ -2116,7 +2111,7 @@ protected void appendConstrainedImplements(
for (final JvmParameterizedTypeReference superType : implementedtypes) {
if (!Objects.equal(owner.getIdentifier(), superType.getIdentifier())
&& superType.getType() instanceof JvmGenericType
&& this.inheritanceHelper.isProxyOrSubTypeOf(superType, defaultJvmType, defaultSarlType, true)) {
/*&& this.inheritanceHelper.isProxyOrSubTypeOf(superType, defaultJvmType, defaultSarlType, true)*/) {
owner.getSuperTypes().add(this.typeBuilder.cloneWithProxies(superType));
context.incrementSerial(superType.getIdentifier().hashCode());
explicitType = true;
Expand Down
Expand Up @@ -130,8 +130,8 @@ public void recursiveAgentExtension_1() throws Exception {

validate(mas).assertError(
SarlPackage.eINSTANCE.getSarlAgent(),
org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
"The inheritance hierarchy of 'A2' is inconsistent");
IssueCodes.INVALID_EXTENDED_TYPE,
"Supertype must be of type 'io.sarl.lang.core.Agent'");
}

@Test
Expand All @@ -147,8 +147,8 @@ public void recursiveAgentExtension_2() throws Exception {

validate(mas).assertError(
SarlPackage.eINSTANCE.getSarlAgent(),
org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
"The inheritance hierarchy of 'A2' is inconsistent");
IssueCodes.INVALID_EXTENDED_TYPE,
"Supertype must be of type 'io.sarl.lang.core.Agent'");
}

@Test
Expand Down
Expand Up @@ -121,8 +121,8 @@ public void invalidExtend_3() throws Exception {
));
validate(mas).assertError(
SarlPackage.eINSTANCE.getSarlBehavior(),
org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
"The inheritance hierarchy of 'B2' is inconsistent");
IssueCodes.INVALID_EXTENDED_TYPE,
"Supertype must be of type 'io.sarl.lang.core.Behavior'");
}

@Test
Expand All @@ -137,8 +137,8 @@ public void invalidExtend_4() throws Exception {
));
validate(mas).assertError(
SarlPackage.eINSTANCE.getSarlBehavior(),
org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
"The inheritance hierarchy of 'B2' is inconsistent");
IssueCodes.INVALID_EXTENDED_TYPE,
"Supertype must be of type 'io.sarl.lang.core.Behavior'");
}

@Test
Expand All @@ -153,8 +153,8 @@ public void invalidExtend_5() throws Exception {
));
validate(mas).assertError(
SarlPackage.eINSTANCE.getSarlBehavior(),
org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
"The inheritance hierarchy of 'B1' is inconsistent");
IssueCodes.INVALID_EXTENDED_TYPE,
"Supertype must be of type 'io.sarl.lang.core.Behavior'");
}

@Test
Expand Down
Expand Up @@ -366,8 +366,8 @@ public void invalidCapacityExtend_13() throws Exception {
));
validate(mas).assertError(
SarlPackage.eINSTANCE.getSarlCapacity(),
org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
"The inheritance hierarchy of 'C1' is inconsistent");
IssueCodes.INVALID_EXTENDED_TYPE,
"Supertype must be of type 'io.sarl.lang.core.Capacity'");
}

@Test
Expand All @@ -382,8 +382,8 @@ public void invalidCapacityExtend_14() throws Exception {
));
validate(mas).assertError(
SarlPackage.eINSTANCE.getSarlCapacity(),
org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
"The inheritance hierarchy of 'C1' is inconsistent");
IssueCodes.INVALID_EXTENDED_TYPE,
"Supertype must be of type 'io.sarl.lang.core.Capacity'");
}

@Test
Expand Down
Expand Up @@ -466,52 +466,4 @@ public void fixInconsistentTypeHierarchy_0() {
"capacity C1 { }");
}

/**
*/
@Test
public void fixInconsistentTypeHierarchy_1() {
assertQuickFix(org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
//
// Code to fix:
//
multilineString(
"capacity C1 extends C2 { }",
"capacity C2 extends C1 { }"),
//
// Label and description:
//
"Remove C2",
//
// Expected fixed code:
//
multilineString(
"capacity C1 { }",
"capacity C2 extends C1 { }"));
}

/**
*/
@Test
public void fixInconsistentTypeHierarchy_2() {
assertQuickFix(org.eclipse.xtend.core.validation.IssueCodes.CYCLIC_INHERITANCE,
//
// Code to fix:
//
multilineString(
"capacity C1 extends C2 { }",
"capacity C2 extends C3 { }",
"capacity C3 extends C1 { }"),
//
// Label and description:
//
"Remove C2",
//
// Expected fixed code:
//
multilineString(
"capacity C1 { }",
"capacity C2 extends C3 { }",
"capacity C3 extends C1 { }"));
}

}

0 comments on commit 3e664fb

Please sign in to comment.