Index: src/ResolvExpr/CandidateFinder.cpp
===================================================================
--- src/ResolvExpr/CandidateFinder.cpp	(revision 16ba4897edb8e47f2990f485549b0053dee60bae)
+++ src/ResolvExpr/CandidateFinder.cpp	(revision 90be0cf4038a0d324a55f8ab409c9aa1b4ba02e2)
@@ -2136,4 +2136,18 @@
 }
 
+/// If the target enum is a child, get the offset from the base to the target.
+static unsigned findChildOffset(
+		const ast::EnumDecl * decl, const ast::EnumDecl * target ) {
+	unsigned offset = 0;
+	for ( auto inlined : decl->inlinedDecl ) {
+		auto childDecl = inlined->base;
+		if ( childDecl == target ) {
+			return offset;
+		}
+		offset += childDecl->members.size();
+	}
+	SemanticError( decl, "Cannot find the target enum." );
+}
+
 const ast::Expr * CandidateFinder::makeEnumOffsetCast( const ast::EnumInstType * src, 
 	const ast::EnumInstType * dst, const ast::Expr * expr, Cost minCost ) {
@@ -2147,9 +2161,9 @@
 		ast::CastExpr * castToDst;
 		if (c<minCost) {
-			unsigned offset = dstDecl->calChildOffset(dstChild.get());
+			unsigned offset = findChildOffset( dstDecl, dstChild.get()->base );
 			if (offset > 0) {
 				auto untyped = ast::UntypedExpr::createCall(
-					expr->location, 
-					"?+?", 
+					expr->location,
+					"?+?",
 					{ new ast::CastExpr( expr->location,
 						expr,
Index: src/ResolvExpr/CommonType.cpp
===================================================================
--- src/ResolvExpr/CommonType.cpp	(revision 16ba4897edb8e47f2990f485549b0053dee60bae)
+++ src/ResolvExpr/CommonType.cpp	(revision 90be0cf4038a0d324a55f8ab409c9aa1b4ba02e2)
@@ -636,4 +636,14 @@
 	void postvisit( const ast::UnionInstType * ) {}
 
+	/// Is the target enum a child of the base enum?
+	static bool isChildEnum(
+			const ast::EnumDecl * decl, const ast::EnumDecl * target ) {
+		if ( decl == target ) return true;
+		for ( auto inlined : decl->inlinedDecl ) {
+			if ( isChildEnum( inlined->base, target ) ) return true;
+		}
+		return false;
+	}
+
 	void postvisit( const ast::EnumInstType * param ) {
 		auto argAsEnumInst = dynamic_cast<const ast::EnumInstType *>(type2);
@@ -641,5 +651,7 @@
 			const ast::EnumDecl* paramDecl = param->base;
 			const ast::EnumDecl* argDecl = argAsEnumInst->base;
-			if (argDecl->isSubTypeOf(paramDecl)) result = param;
+			if ( isChildEnum( paramDecl, argDecl ) ) {
+				result = param;
+			}
 		} else if ( param->base && !param->base->isCfa ) {
 			auto basicType = new ast::BasicType( ast::BasicKind::UnsignedInt );
