Skip to content

Commit

Permalink
Use re-stated types in definition imports (see #760)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Oct 29, 2020
1 parent e5b2e9f commit bd2643b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.overture.ast.definitions.SClassDefinition;
import org.overture.ast.factory.AstFactory;
import org.overture.ast.node.INode;
import org.overture.ast.types.AFunctionType;
import org.overture.ast.types.AUnionType;
import org.overture.ast.types.PType;
import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
Expand Down Expand Up @@ -146,7 +147,18 @@ public PType caseAImplicitOperationDefinition(
public PType caseAImportedDefinition(AImportedDefinition node)
throws AnalysisException
{
return ((AImportedDefinition) node).getDef().apply(THIS);
PType type = node.getType();

if (type != null && !(type instanceof AFunctionType))
{
// Only for non-function types (polymorphic params cause trouble)
// See bug #760
return type;
}
else
{
return ((AImportedDefinition) node).getDef().apply(THIS);
}
}

public static void checkSuperDefinition(AInheritedDefinition d)
Expand Down Expand Up @@ -231,7 +243,18 @@ public PType caseAPerSyncDefinition(APerSyncDefinition node)
public PType caseARenamedDefinition(ARenamedDefinition node)
throws AnalysisException
{
return ((ARenamedDefinition) node).getDef().apply(THIS);
PType type = node.getType();

if (type != null && !(type instanceof AFunctionType))
{
// Only for non-function types (polymorphic params cause trouble)
// See bug #760
return type;
}
else
{
return ((ARenamedDefinition) node).getDef().apply(THIS);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public List<PDefinition> defaultSValueImport(SValueImport imp,
{
expdef = AstFactory.newAImportedDefinition(imp.getLocation(), expdef);
}

if (imp.getImportType() != null)
{
expdef.setType(imp.getImportType());
}

list.add(expdef);
}
Expand Down

0 comments on commit bd2643b

Please sign in to comment.