diff --git a/include/clang/ASTMatchers/ASTMatchersInternal.h b/include/clang/ASTMatchers/ASTMatchersInternal.h
index a89b37a6b2378b1a3745c9b013417f35635e17ef..f00277c1a6126f5fd01c4b11ad2dcafda848546f 100644
--- a/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -367,7 +367,10 @@ public:
   Matcher(const Matcher<From> &Other,
           typename std::enable_if<std::is_base_of<From, T>::value &&
                                   !std::is_same<From, T>::value>::type * = 0)
-      : Matcher(Other.Implementation) {}
+      : Implementation(restrictMatcher(Other.Implementation)) {
+    assert(Implementation.getSupportedKind().isSame(
+        ast_type_traits::ASTNodeKind::getFromNodeKind<T>()));
+  }
 
   /// \brief Implicitly converts \c Matcher<Type> to \c Matcher<QualType>.
   ///
@@ -432,9 +435,12 @@ public:
 private:
   template <typename U> friend class Matcher;
 
+  static DynTypedMatcher restrictMatcher(const DynTypedMatcher &Other) {
+    return Other.dynCastTo(ast_type_traits::ASTNodeKind::getFromNodeKind<T>());
+  }
+
   explicit Matcher(const DynTypedMatcher &Implementation)
-      : Implementation(Implementation.dynCastTo(
-            ast_type_traits::ASTNodeKind::getFromNodeKind<T>())) {
+      : Implementation(restrictMatcher(Implementation)) {
     assert(this->Implementation.getSupportedKind()
                .isSame(ast_type_traits::ASTNodeKind::getFromNodeKind<T>()));
   }