From c3ca711c49760e7f9467afd0811a0427c67e0dc1 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Sun, 18 Jan 2015 17:14:20 +0800 Subject: Generic param checks passing --- src/convert/resolve.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/convert/resolve.cpp') diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp index 3fd7b7ea..2e961f1f 100644 --- a/src/convert/resolve.cpp +++ b/src/convert/resolve.cpp @@ -44,6 +44,7 @@ public: CPathResolver(const AST::Crate& crate); virtual void handle_path(AST::Path& path, CASTIterator::PathMode mode) override; + virtual void handle_type(TypeRef& type) override; virtual void handle_expr(AST::ExprNode& node) override; virtual void handle_pattern(AST::Pattern& pat, const TypeRef& type_hint) override; @@ -207,6 +208,7 @@ void CPathResolver::handle_path(AST::Path& path, CASTIterator::PathMode mode) if( mode == MODE_TYPE ) { DEBUG("Local type " << path[0].name()); + throw ParseError::BugCheck("Local types should be handled in handle_type"); return ; } @@ -271,6 +273,22 @@ void CPathResolver::handle_path(AST::Path& path, CASTIterator::PathMode mode) throw ParseError::Generic("Name resolution failed"); } } +void CPathResolver::handle_type(TypeRef& type) +{ + if( type.is_path() && type.path().is_relative() && type.path().size() == 1 ) + { + const auto& name = type.path()[0].name(); + if( lookup_local(LocalItem::TYPE, name).is_some() ) + { + type = TypeRef(TypeRef::TagArg(), name); + } + else + { + // Not a type param, fall back to other checks + } + } + CASTIterator::handle_type(type); +} void CPathResolver::handle_expr(AST::ExprNode& node) { CResolvePaths_NodeVisitor nv(*this); -- cgit v1.2.3