This commit is contained in:
Daniel Kirchner 2023-06-25 08:48:48 +02:00
parent 58b7344c5a
commit 2e9b844d65
3 changed files with 4 additions and 9 deletions

View File

@ -104,12 +104,7 @@ private:
GlobalAnnotation& annotation(); GlobalAnnotation& annotation();
void unify(Type _a, Type _b, langutil::SourceLocation _location = {}, TypeEnvironment* _env = nullptr); void unify(Type _a, Type _b, langutil::SourceLocation _location = {}, TypeEnvironment* _env = nullptr);
enum class ExpressionContext enum class ExpressionContext { Term, Type, Sort };
{
Term,
Type,
Sort
};
Type handleIdentifierByReferencedDeclaration(langutil::SourceLocation _location, Declaration const& _declaration); Type handleIdentifierByReferencedDeclaration(langutil::SourceLocation _location, Declaration const& _declaration);
ExpressionContext m_expressionContext = ExpressionContext::Term; ExpressionContext m_expressionContext = ExpressionContext::Term;
}; };

View File

@ -289,15 +289,14 @@ std::string TypeEnvironmentHelpers::canonicalTypeName(Type _type) const
}; };
std::visit(util::GenericVisitor{ std::visit(util::GenericVisitor{
[&](Declaration const* _declaration) { [&](Declaration const* _declaration) {
printTypeArguments();
if (auto const* typeDeclarationAnnotation = dynamic_cast<TypeDeclarationAnnotation const*>(&_declaration->annotation())) if (auto const* typeDeclarationAnnotation = dynamic_cast<TypeDeclarationAnnotation const*>(&_declaration->annotation()))
stream << *typeDeclarationAnnotation->canonicalName; stream << *typeDeclarationAnnotation->canonicalName;
else else
// TODO: canonical name // TODO: canonical name
stream << _declaration->name(); stream << _declaration->name();
printTypeArguments();
}, },
[&](BuiltinType _builtinType) { [&](BuiltinType _builtinType) {
printTypeArguments();
switch(_builtinType) switch(_builtinType)
{ {
case BuiltinType::Type: case BuiltinType::Type:
@ -331,6 +330,7 @@ std::string TypeEnvironmentHelpers::canonicalTypeName(Type _type) const
stream << "integer"; stream << "integer";
break; break;
} }
printTypeArguments();
} }
}, _type.constructor); }, _type.constructor);
return stream.str(); return stream.str();

View File

@ -1822,12 +1822,12 @@ ASTPointer<TypeClassInstantiation> Parser::parseTypeClassInstantiation()
expectToken(Token::Instantiation); expectToken(Token::Instantiation);
// TODO: parseTypeConstructor() // TODO: parseTypeConstructor()
ASTPointer<TypeName> typeConstructor = parseTypeName(); ASTPointer<TypeName> typeConstructor = parseTypeName();
expectToken(Token::Colon);
ASTPointer<ParameterList> argumentSorts; ASTPointer<ParameterList> argumentSorts;
if (m_scanner->currentToken() == Token::LParen) if (m_scanner->currentToken() == Token::LParen)
{ {
argumentSorts = parseParameterList(); argumentSorts = parseParameterList();
} }
expectToken(Token::Colon);
ASTPointer<TypeClassName> typeClassName = parseTypeClassName(); ASTPointer<TypeClassName> typeClassName = parseTypeClassName();
expectToken(Token::LBrace); expectToken(Token::LBrace);
while (true) while (true)