From c5e36d31aff30492a7d6f30c761cbf4b333feda2 Mon Sep 17 00:00:00 2001 From: Guilherme Ottoni Date: Tue, 14 May 2013 05:44:43 -0700 Subject: [PATCH] Predict that constructors return KindOfNull If we can't infer it, then predict it. --- hphp/compiler/analysis/emitter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hphp/compiler/analysis/emitter.cpp b/hphp/compiler/analysis/emitter.cpp index 8522c6112..371c828c9 100644 --- a/hphp/compiler/analysis/emitter.cpp +++ b/hphp/compiler/analysis/emitter.cpp @@ -3427,13 +3427,19 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) { } e.FCall(numParams); - if (Option::WholeProgram) { + bool inferred = false; + if (Option::WholeProgram && Option::GenerateInferredTypes) { FunctionScopePtr fs = ne->getFuncScope(); if (fs && !fs->getReturnType()) { - m_evalStack.setKnownType(KindOfNull, false /* inferred */); + m_evalStack.setKnownType(KindOfNull, false /* it's inferred */); m_evalStack.setNotRef(); + inferred = true; } } + if (!inferred) { + m_evalStack.setKnownType(KindOfNull, true /* it's predicted */); + m_evalStack.setNotRef(); + } e.PopR(); return true; }