Index: src/ResolvExpr/CandidateFinder.cpp
===================================================================
--- src/ResolvExpr/CandidateFinder.cpp	(revision 9d5eacb77f6659b84df326bf35fe21bcde7e425b)
+++ src/ResolvExpr/CandidateFinder.cpp	(revision 76b507d24aba8184d760ef5fb795294bcdca3103)
@@ -1485,10 +1485,32 @@
 
 	void Finder::postvisit( const ast::CountExpr * countExpr ) {
-		assert( countExpr->type );
-		auto enumInst = countExpr->type.as<ast::EnumInstType>();
-		if ( !enumInst ) {
-			SemanticError( countExpr, "Count Expression only supports Enum Type as operand: ");
-		}
-		addCandidate( ast::ConstantExpr::from_ulong(countExpr->location, enumInst->base->members.size()), tenv );
+		const ast::UntypedExpr * untyped;
+		if ( countExpr->type ) {
+			auto enumInst = countExpr->type.as<ast::EnumInstType>();
+			if ( enumInst ) {
+				addCandidate( ast::ConstantExpr::from_ulong(countExpr->location, enumInst->base->members.size()), tenv );
+				return;
+			}
+			auto untypedFirst = ast::UntypedExpr::createCall( countExpr->location, "lowerBound", {} );
+			auto castFirst = new ast::CastExpr( countExpr->location, untypedFirst , countExpr->type );
+			untyped = ast::UntypedExpr::createCall(
+				countExpr->location, "Countof", { castFirst }
+			);
+		}
+		if (!untyped) untyped = ast::UntypedExpr::createCall(
+				countExpr->location, "Countof", { countExpr->expr }
+		);
+		CandidateFinder finder( context, tenv );
+		finder.find( untyped );
+		CandidateList winners = findMinCost( finder.candidates );
+		if ( winners.size() == 0 ) {
+			SemanticError( countExpr->expr, "Countof is not implemented for operand: " );
+		}
+		if ( winners.size() !=  1 ) {
+			SemanticError( countExpr->expr, "Ambiguous expression in countof operand: " );
+		}
+		CandidateRef & choice = winners.front();
+		choice->expr = referenceToRvalueConversion( choice->expr, choice->cost );
+		addCandidate( *choice, choice->expr );
 	}
 
