Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a2d1926
initial TypeCheck3
SE-FDr May 19, 2026
5960872
use TypeCheck3 in CDDiffUtil and TypeCheckMCTypeMatchingStrategy
Jun 24, 2026
b7c2005
refactor: Migrate ISynthesize to TypeCheck3; (constructor changes may…
0-ace-l0 Jun 29, 2026
4c92c13
Merge branch 'dev' into tc3
Jul 1, 2026
c4d296e
remove getDefiningSymbol()
0-ace-l0 Jul 8, 2026
a8fb0e2
replace isObjectType with isObscureType
Jul 8, 2026
2b434f5
add MCArrayTypes to CD4A and CD4C TypeCheck3
Jul 22, 2026
5fa7c98
Merge remote-tracking branch 'origin/dev' into tc3
luepges Sep 9, 2026
04b6cb7
fix cdgen duplicate scopes and fake types
luepges Sep 9, 2026
f327870
Add MCFullGenericTypesTypeVisitor to CD4Code
luepges Sep 9, 2026
c2414c8
fmt
luepges Sep 9, 2026
599c878
Update fake types
luepges Sep 9, 2026
e31f7d1
Improve cd gradle test reporting
luepges Sep 9, 2026
456bfc9
fix gradle test wrt mavenLocal
luepges Sep 9, 2026
d7b1ea3
init Test-CD4CodeBasis-TC3 for test
luepges Sep 9, 2026
6546b24
add javadocs
luepges Sep 9, 2026
bed7f29
Disable failing tests with a TODO
luepges Sep 10, 2026
e38db05
add version property to symtabdef test
luepges Sep 10, 2026
8959da3
fix main class usage in tests
luepges Sep 10, 2026
d5bbf6b
workaround for CDBasisDefaultPackageTrafo
luepges Sep 10, 2026
2f34228
fix dependsOn
luepges Sep 10, 2026
2266050
Disable duplicate symbol cd-diff tools
luepges Sep 10, 2026
a64bf2c
Handle qualified types of moved packages
luepges Sep 11, 2026
cd2c3cd
Merge branch 'dev' into tc3
luepges Sep 11, 2026
5d2b7ab
cleanup
luepges Sep 11, 2026
302af32
Merge remote-tracking branch 'origin/tc3' into tc3
luepges Sep 14, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.common.collect.Lists;
import de.monticore.cd._symboltable.CDSymbolTables;
import de.monticore.cd4code.CD4CodeMill;
import de.monticore.cd4code.typescalculator.FullSynthesizeFromCD4Code;
import de.monticore.cdbasis._symboltable.ICDBasisScope;
import de.monticore.cd4codebasis._ast.ASTCDMethod;
import de.monticore.cd4codebasis._ast.ASTCDParameter;
Expand All @@ -18,13 +17,13 @@
import de.monticore.cdconcretization.util.NameUtil;
import de.monticore.symbols.basicsymbols._ast.ASTType;
import de.monticore.symbols.basicsymbols._symboltable.TypeSymbolTOP;
import de.monticore.types.check.ISynthesize;
import de.monticore.types.check.SymTypeExpression;
import de.monticore.types.mcbasictypes._ast.ASTMCPrimitiveType;
import de.monticore.types.mcbasictypes._ast.ASTMCQualifiedType;
import de.monticore.types.mcbasictypes._ast.ASTMCReturnType;
import de.monticore.types.mcbasictypes._ast.ASTMCType;
import de.monticore.types.mccollectiontypes._ast.*;
import de.monticore.types3.TypeCheck3;
import de.se_rwth.commons.logging.Log;

import java.util.*;
Expand All @@ -33,8 +32,6 @@
/** Completes a concrete type by adding the given reference method if it is not already present. */
public class BaseMethodInTypeCompleter extends AbstractMethodInTypeCompleter {

private final ISynthesize typeCalculator = new FullSynthesizeFromCD4Code();

@Override
public void completeMethodInType(ASTCDType concreteType, ASTCDMethod referenceMethod,
TypeCompletionContext context) {
Expand Down Expand Up @@ -90,7 +87,7 @@ private void createMethodIncarnations(ASTCDType concreteType, ASTCDMethod refere
* @return a list of all incarnations of the given reference type
*/
private List<ASTMCType> findTypeIncarnations(ASTMCType refMCType, TypeCompletionContext context) {
SymTypeExpression symTypeExpr = typeCalculator.synthesizeType(refMCType).getResult();
SymTypeExpression symTypeExpr = TypeCheck3.symTypeFromAST(refMCType);

// make sure we do not add the 'any' type to the concrete CD
if (symTypeExpr.getTypeInfo().getFullName().equals(context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import de.monticore.cdconcretization.util.SymbolUtil;
import de.monticore.cdconformance.CDConfParameter;
import de.monticore.cdconformance.inc.MethodOverloadingOOSymbolsIncMapping;
import de.monticore.symboltable.ISymbol;
import de.monticore.types.check.SymTypeExpression;
import de.monticore.types3.TypeCheck3;
import de.se_rwth.commons.Names;

import java.util.List;
Expand Down Expand Up @@ -158,14 +161,20 @@ private void completeMethodUsingType(ASTCDMethod referenceMethod, ASTCDType para
ASTCDMethod newMethod = cloneWithOriginalTypes(referenceMethod);

// 1. decide return type of the new method
if (referenceMethod.getMCReturnType().isPresentMCType() && referenceMethod.getMCReturnType()
.getMCType().getDefiningSymbol().get().getFullName().equals(paramType.getSymbol()
.getFullName())) {
// Convention: If the param attribute type matches the reference method return type
// -> Use the attribute incarnation type as return type
newMethod.setMCReturnType(CD4CodeMill.mCReturnTypeBuilder().setMCType(
createQualifiedTypeInScope(context.getConcreteType().getSpannedScope(), paramTypeInc
.getSymbol().getInternalQualifiedName())).build());
if (referenceMethod.getMCReturnType().isPresentMCType()) {
SymTypeExpression returnSymType = TypeCheck3.symTypeFromAST(referenceMethod
.getMCReturnType().getMCType());
if (!returnSymType.isObscureType() && returnSymType.getSourceInfo().getSourceSymbol()
.isPresent()) {
ISymbol returnSymbol = returnSymType.getSourceInfo().getSourceSymbol().get();
if (returnSymbol.getFullName().equals(paramType.getSymbol().getFullName())) {
// Convention: If the param attribute type matches the reference method return type
// -> Use the attribute incarnation type as return type
newMethod.setMCReturnType(CD4CodeMill.mCReturnTypeBuilder().setMCType(
createQualifiedTypeInScope(context.getConcreteType().getSpannedScope(), paramTypeInc
.getSymbol().getInternalQualifiedName())).build());
}
}
}
// ELSE: Default: keep the return type of the reference method resp.

Expand All @@ -183,16 +192,22 @@ private void completeMethodUsingType(ASTCDMethod referenceMethod, ASTCDType para
// ELSE: parameter name stays as is! only needs to be unique in scope of the method

// 2.2 parameter type
if (referenceParameter.getMCType().getDefiningSymbol().get().getFullName().equals(paramType
.getSymbol().getFullName())) {
// TODO naming is weird when we talk about parameters and a parameter element!
// Convention: If the param type matches the reference method parameter type
// -> Use the type incarnation as parameter type
newParameter.setMCType(createQualifiedTypeInScope(context.getConcreteType()
.getEnclosingScope(), paramTypeInc.getSymbol().getInternalQualifiedName()));
parameterSignatureAdapted = true;
SymTypeExpression referenceSymType = TypeCheck3.symTypeFromAST(referenceParameter
.getMCType());
if (!referenceSymType.isObscureType() && referenceSymType.getSourceInfo().getSourceSymbol()
.isPresent()) {
ISymbol referenceSymbol = referenceSymType.getSourceInfo().getSourceSymbol().get();
if (referenceSymbol.getFullName().equals(paramType.getSymbol().getFullName())) {
// TODO naming is weird when we talk about parameters and a parameter element!
// Convention: If the param type matches the reference method parameter type
// -> Use the type incarnation as parameter type
newParameter.setMCType(createQualifiedTypeInScope(context.getConcreteType()
.getEnclosingScope(), paramTypeInc.getSymbol().getInternalQualifiedName()));
parameterSignatureAdapted = true;
}
// ELSE: Default: keep the parameter type of the reference method resp.

}
// ELSE: Default: keep the parameter type of the reference method resp.
}

// 3. decide name of the new method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import de.monticore.cdbasis._symboltable.CDTypeSymbol;
import de.monticore.cdbasis._visitor.CDBasisVisitor2;
import de.monticore.symboltable.ISymbol;
import de.monticore.types.check.SymTypeExpression;
import de.monticore.types.mcbasictypes._ast.ASTMCType;
import de.monticore.types.mcbasictypes._visitor.MCBasicTypesVisitor2;
import de.monticore.types3.TypeCheck3;

import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -75,8 +77,9 @@ public void visit(ASTCDMethod conMethod) {

@Override
public void visit(ASTMCType conType) {
if (conType.getDefiningSymbol().isPresent()) {
ISymbol conTypeSymbol = conType.getDefiningSymbol().get();
SymTypeExpression symType = TypeCheck3.symTypeFromAST(conType);
if (!symType.isObscureType() && symType.getSourceInfo().getSourceSymbol().isPresent()) {
ISymbol conTypeSymbol = symType.getSourceInfo().getSourceSymbol().get();
if (conTypeSymbol instanceof CDTypeSymbol && conTypeSymbol.isPresentAstNode()) {
ASTCDType concreteType = (ASTCDType) conTypeSymbol.getAstNode();
incMapping.getReferenceElements(concreteType).forEach(refType -> typeIncs.put(refType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.cdconformance.inc.mctype;

import de.monticore.cd4code.typescalculator.FullSynthesizeFromCD4Code;
import de.monticore.cdbasis._ast.ASTCDType;
import de.monticore.cdmatcher.BooleanMatchingStrategy;
import de.monticore.types.check.ISynthesize;
import de.monticore.types.check.SymTypeExpression;
import de.monticore.types.mcbasictypes._ast.ASTMCType;
import de.monticore.types3.TypeCheck3;
import de.monticore.types3.generics.bounds.Bound;
import de.se_rwth.commons.logging.Log;

Expand All @@ -24,12 +23,10 @@
public class TypeCheckMCTypeMatchingStrategy implements MCTypeMatchingStrategy {

protected String underspecifiedTypeName;
protected ISynthesize typeCalculator; // TODO Use TypeCheck3 once available
protected IncMappingAwareSymTypeCompatibilityCalculator compatibilityCalculator;

public TypeCheckMCTypeMatchingStrategy(String underspecifiedTypeName) {
this.underspecifiedTypeName = underspecifiedTypeName;
this.typeCalculator = new FullSynthesizeFromCD4Code();
this.compatibilityCalculator = new IncMappingAwareSymTypeCompatibilityCalculator();
}

Expand All @@ -51,9 +48,8 @@ public boolean isMatched(ASTMCType conType, ASTMCType refType,
// every type is allowed if the reference type is underspecified
return true;
}
// TODO Use TypeCheck3
SymTypeExpression concreteType = typeCalculator.synthesizeType(conType).getResult();
SymTypeExpression referenceType = typeCalculator.synthesizeType(refType).getResult();
SymTypeExpression concreteType = TypeCheck3.symTypeFromAST(conType);
SymTypeExpression referenceType = TypeCheck3.symTypeFromAST(refType);
/*
* Compatibility calculator knows the incarnation mapping and checks if the concrete
* type is an incarnation of the reference type.if both are CDTypeSymbols.
Expand Down
63 changes: 44 additions & 19 deletions cddiff/src/main/java/de/monticore/cddiff/CDDiffUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import de.monticore.cd4code._symboltable.CD4CodeSymbolTableCompleter;
import de.monticore.cd4code._symboltable.ICD4CodeArtifactScope;
import de.monticore.cd4code._visitor.CD4CodeTraverser;
import de.monticore.cd4code.typescalculator.FullSynthesizeFromCD4Code;
import de.monticore.cdassociation._ast.ASTCDAssocSide;
import de.monticore.cdassociation._ast.ASTCDAssociation;
import de.monticore.cdbasis._ast.*;
Expand All @@ -17,10 +16,11 @@
import de.monticore.od4report.OD4ReportMill;
import de.monticore.od4report._parser.OD4ReportParser;
import de.monticore.odbasis._ast.ASTODArtifact;
import de.monticore.symboltable.ISymbol;
import de.monticore.symboltable.ImportStatement;
import de.monticore.types.check.ISynthesize;
import de.monticore.types.check.SymTypeExpression;
import de.monticore.types.mcbasictypes._ast.ASTMCObjectType;
import de.monticore.types3.TypeCheck3;
import de.se_rwth.commons.logging.Log;
import java.io.IOException;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -181,10 +181,19 @@ public static Set<ASTCDClass> getAllSuperclasses(ASTCDClass astcdClass,
String superName;
if (currentClass.isPresentCDExtendUsage()) {
for (ASTMCObjectType objectType : currentClass.getCDExtendUsage().getSuperclassList()) {
assert objectType.getDefiningSymbol().isPresent();
superName = ((CDTypeSymbol) objectType.getDefiningSymbol().get())
.getInternalQualifiedName();

SymTypeExpression symtype = TypeCheck3.symTypeFromAST(objectType);
if (!symtype.isObscureType() && symtype.getSourceInfo().getSourceSymbol().isPresent()) {
ISymbol symbol = symtype.getSourceInfo().getSourceSymbol().get();
if (symbol instanceof CDTypeSymbol) {
superName = ((CDTypeSymbol) symbol).getInternalQualifiedName();
}
else {
continue;
}
}
else {
continue;
}
for (ASTCDClass astClass : classes) {
if (superName.equals(astClass.getSymbol().getInternalQualifiedName())) {
toProcess.add(astClass);
Expand Down Expand Up @@ -212,9 +221,19 @@ public static Set<ASTCDInterface> getAllInterfaces(ASTCDClass superClass,

String interfaceName;
for (ASTMCObjectType objectType : superClass.getInterfaceList()) {
assert objectType.getDefiningSymbol().isPresent();
interfaceName = ((CDTypeSymbol) objectType.getDefiningSymbol().get())
.getInternalQualifiedName();
SymTypeExpression symtype = TypeCheck3.symTypeFromAST(objectType);
Comment thread
luepges marked this conversation as resolved.
if (!symtype.isObscureType() && symtype.getSourceInfo().getSourceSymbol().isPresent()) {
ISymbol symbol = symtype.getSourceInfo().getSourceSymbol().get();
if (symbol instanceof CDTypeSymbol) {
interfaceName = ((CDTypeSymbol) symbol).getInternalQualifiedName();
}
else {
continue;
}
}
else {
continue;
}

for (ASTCDInterface allowedInterface : allowedInterfaces) {
if (interfaceName.equals(allowedInterface.getSymbol().getInternalQualifiedName())) {
Expand All @@ -234,9 +253,19 @@ public static Set<ASTCDInterface> getAllInterfaces(ASTCDClass superClass,
// Add all interfaces implemented by the current interface to the
// processing list
for (ASTMCObjectType objectType : currentInterface.getInterfaceList()) {
assert objectType.getDefiningSymbol().isPresent();
interfaceName = ((CDTypeSymbol) objectType.getDefiningSymbol().get())
.getInternalQualifiedName();
SymTypeExpression symtype = TypeCheck3.symTypeFromAST(objectType);
if (!symtype.isObscureType() && symtype.getSourceInfo().getSourceSymbol().isPresent()) {
ISymbol symbol = symtype.getSourceInfo().getSourceSymbol().get();
if (symbol instanceof CDTypeSymbol) {
interfaceName = ((CDTypeSymbol) symbol).getInternalQualifiedName();
}
else {
continue;
}
}
else {
continue;
}

for (ASTCDInterface allowedInterface : allowedInterfaces) {
if (interfaceName.equals(allowedInterface.getSymbol().getInternalQualifiedName())) {
Expand Down Expand Up @@ -325,15 +354,11 @@ public static Set<ASTCDType> getAllSuperTypes(ASTCDType type, ASTCDDefinition cd
/** A helper function to compute all associations in cd that reference astcdType. */
public static Set<ASTCDAssociation> getReferencingAssociations(ASTCDType astcdType,
ASTCDCompilationUnit cd) {
// TODO Use TypeCheck3
ISynthesize typeSynthesizer = new FullSynthesizeFromCD4Code();

String typeFullName = astcdType.getSymbol().getFullName();
return cd.getCDDefinition().getCDAssociationsList().stream().filter(rAssoc -> {
SymTypeExpression leftType = typeSynthesizer.synthesizeType(rAssoc.getLeft()
.getMCQualifiedType()).getResult();
SymTypeExpression rightType = typeSynthesizer.synthesizeType(rAssoc.getRight()
.getMCQualifiedType()).getResult();
SymTypeExpression leftType = TypeCheck3.symTypeFromAST(rAssoc.getLeft().getMCQualifiedType());
SymTypeExpression rightType = TypeCheck3.symTypeFromAST(rAssoc.getRight()
.getMCQualifiedType());
if (!leftType.hasTypeInfo() || !rightType.hasTypeInfo()) {
Log.error("Could not get type for association sides" + CD4CodeMill.prettyPrint(rAssoc,
false));
Expand Down
Loading
Loading