Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ assertj_version = 3.21.0
junit_version = 5.8.2

# Version of published artifacts
version = 7.8.83
version = 7.8.84
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.monticore.lang.sysmlv2.types3;

import de.monticore.types.check.SymTypeExpression;

/**
* Dient dazu die MontiCore Built-Ins (int, String, boolean, nat) mit den
* KerML-ScalarValues (Integer, String, Boolean, Natural/Positive) kompatibel
* zu machen.
*/
public class SysMLBuiltInTypeRelations extends de.monticore.types3.util.BuiltInTypeRelations{
Comment thread
MKZaito marked this conversation as resolved.

@Override
public boolean isIntegralType(SymTypeExpression type) {
return super.isIntegralType(type)
|| (type.isPrimitive()
&& type.asPrimitive().getPrimitiveName().equals("nat"))
|| (type.hasTypeInfo()
&& (
type.getTypeInfo().getFullName().equals("ScalarValues.Integer") ||
type.getTypeInfo().getFullName().equals("ScalarValues.Natural") ||
type.getTypeInfo().getFullName().equals("ScalarValues.Positive"))
);
}

@Override
public boolean isBoolean(SymTypeExpression type) {
return super.isBoolean(type) ||
(type.hasTypeInfo() &&
type.getTypeInfo().getFullName().equals("ScalarValues.Boolean"));
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package de.monticore.lang.sysmlv2.types3;

import de.monticore.ocl.types3.OCLSymTypeRelations;
import de.monticore.types.check.SymTypeExpression;
import de.monticore.types3.util.BuiltInTypeRelations;
import de.monticore.types3.util.SymTypeCompatibilityCalculator;
import de.monticore.types3.util.SymTypeRelationsDefaultDelegatee;

public abstract class SysMLSymTypeRelations extends OCLSymTypeRelations {
Expand All @@ -16,28 +13,7 @@ public static void init() {
protected static class SysMLSymTypeRelationsDelegatee extends
SymTypeRelationsDefaultDelegatee {
public SysMLSymTypeRelationsDelegatee() {
builtInRelationsDelegate = new BuiltInTypeRelations() {
@Override
public boolean isIntegralType(SymTypeExpression type) {
return super.isIntegralType(type) ||
type.isPrimitive() &&
type.asPrimitive().getPrimitiveName().equals("nat");
}

/*
Any Type that is included here will be compatible with any other Type
in the list.
*/
@Override
public boolean isBoolean(SymTypeExpression type) {
return (super.isBoolean(type) ||
(
type.hasTypeInfo() &&
type.getTypeInfo().getFullName().equals("ScalarValues.Boolean")
)
);
}
};
builtInRelationsDelegate = new SysMLBuiltInTypeRelations();
}
}
}
5 changes: 3 additions & 2 deletions language/src/test/java/typecheck/CompareTypesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void clear() {

@ParameterizedTest
@ValueSource(strings = {
"attribute target : boolean; attribute source : ScalarValues::Boolean;"
"attribute target : boolean; attribute source : ScalarValues::Boolean;",
"attribute target : ScalarValues::Integer; attribute source : int;",
})
public void test4CompatibleTypes(String targetAndSource) throws IOException {
var type = typeOfConstraintExpression(targetAndSource);
Expand All @@ -70,7 +71,7 @@ public void test4CompatibleTypes(String targetAndSource) throws IOException {
// int und ScalarValues::Integer sollte erlaubt sein, aber das muss noch implementiert werden
@ParameterizedTest
@ValueSource(strings = {
"attribute target : int; attribute source : ScalarValues::Integer;"
"attribute target : int; attribute source : ScalarValues::String;"
})
public void test4IncompatibleTypes(String targetAndSource) throws IOException {
var type = typeOfConstraintExpression(targetAndSource);
Expand Down
Loading