 
 		return
 
+	resolveXthen = (x, xthen, resolve, reject) ->
+		# TODO: If the promise is a Yaku instance,
+		# not some thing like the Bluebird or jQuery Defer,
+		# we can do some performance optimization.
+		try
+			isResolved = false
+			xthen.call x, (y) ->
+				return if isResolved
+				isResolved = true
+				resolveValue y, resolve, reject
+			, (r) ->
+				return if isResolved
+				isResolved = true
+				reject r
+		catch e
+			reject e if not isResolved
+
+	getXthen = (x, reject) ->
+		try
+			x.then
+		catch e
+			reject e
+			return $tryErr
+
+	getX = (self, offset, handler) ->
+		try
+			handler self._value
+		catch e
+			self[offset + 3] e
+			return $tryErr
+
 	###*
 	 * Decide how handlers works.
 	 * @private

	$groupNum = 5

	$circularErrorInfo = 'circular promise resolution chain'

	# ************************* Private Constant End **************************


	resolveValue = (x, resolve, reject) ->
		type = typeof x
		if x != null and (type == 'function' or type == 'object')
			xthen = getXthen x, reject
			return if xthen == $tryErr

			if typeof xthen == 'function'
				resolveXthen x, xthen, resolve, reject
			else
				resolve x
		else
