Assign built-in function return type in promote()

This finishes the refactoring of unary math operation handling so that
IntermUnary::promote has the complete code for setting the return type of
the node.

BUG=angleproject:952
TEST=angle_unittests, WebGL conformance tests

Change-Id: I19bd8d53029e24f734c9436eceb446b37e7fcf26
Reviewed-on: https://chromium-review.googlesource.com/262416
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 00dbf5e..7ad3f81 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2697,7 +2697,8 @@
     return node;
 }
 
-TIntermTyped *TParseContext::createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc)
+TIntermTyped *TParseContext::createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc,
+    const TType *funcReturnType)
 {
     if (child == nullptr)
     {
@@ -2740,12 +2741,12 @@
         break;
     }
 
-    return intermediate.addUnaryMath(op, child, loc);
+    return intermediate.addUnaryMath(op, child, loc, funcReturnType);
 }
 
 TIntermTyped *TParseContext::addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc)
 {
-    TIntermTyped *node = createUnaryMath(op, child, loc);
+    TIntermTyped *node = createUnaryMath(op, child, loc, nullptr);
     if (node == nullptr)
     {
         unaryOpError(loc, GetOperatorString(op), child->getCompleteString());
@@ -3094,7 +3095,7 @@
                     //
                     // Treat it like a built-in unary operator.
                     //
-                    callNode = createUnaryMath(op, node->getAsTyped(), loc);
+                    callNode = createUnaryMath(op, node->getAsTyped(), loc, &fnCandidate->getReturnType());
                     if (callNode == nullptr)
                     {
                         std::stringstream extraInfoStream;
@@ -3105,18 +3106,6 @@
                         *fatalError = true;
                         return nullptr;
                     }
-                    const TType& returnType = fnCandidate->getReturnType();
-                    if (returnType.getBasicType() == EbtBool)
-                    {
-                        // Bool types should not have precision, so we'll override any precision
-                        // that might have been set by createUnaryMath.
-                        callNode->setType(returnType);
-                    }
-                    else
-                    {
-                        // createUnaryMath has set the precision of the node based on the operand.
-                        callNode->setTypePreservePrecision(returnType);
-                    }
                 }
                 else
                 {