[dart2js] Fix folding of x is Object when x may be null.
Change-Id: Ie45dae49c936e6a163963773747a17006f9554c1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156481 Commit-Queue: Mayank Patke <fishythefish@google.com> Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
2b51d59e69
commit
9b5f0f32ee
@@ -6308,7 +6308,7 @@ class TryCatchFinallyBuilder {
|
||||
|
||||
AbstractValue unwrappedType = kernelBuilder._typeInferenceMap
|
||||
.getReturnTypeOf(kernelBuilder._commonElements.exceptionUnwrapper);
|
||||
if (!kernelBuilder.options.useLegacySubtyping) {
|
||||
if (kernelBuilder.options.useNullSafety) {
|
||||
// Global type analysis does not currently understand that strong mode
|
||||
// `Object` is not nullable, so is imprecise in the return type of the
|
||||
// unwrapper, which leads to unnecessary checks for 'on Object'.
|
||||
@@ -6326,7 +6326,6 @@ class TryCatchFinallyBuilder {
|
||||
int catchesIndex = 0;
|
||||
|
||||
void pushCondition(ir.Catch catchBlock) {
|
||||
// `guard` is often `dynamic`, which generates `true`.
|
||||
kernelBuilder._pushIsTest(catchBlock.guard, unwrappedException,
|
||||
kernelBuilder._sourceInformationBuilder.buildCatch(catchBlock));
|
||||
}
|
||||
|
||||
@@ -4130,26 +4130,30 @@ AbstractBool _isTestResult(
|
||||
AbstractValueDomain abstractValueDomain = closedWorld.abstractValueDomain;
|
||||
AbstractValue subsetType = expression.instructionType;
|
||||
AbstractValue supersetType = checkedAbstractValue.abstractValue;
|
||||
AbstractBool expressionIsNull = expression.isNull(abstractValueDomain);
|
||||
|
||||
if (useNullSafety &&
|
||||
expression.isNull(abstractValueDomain).isDefinitelyTrue) {
|
||||
if (dartType.isObject) return AbstractBool.False;
|
||||
if (closedWorld.dartTypes.isTopType(dartType) ||
|
||||
dartType is NullableType ||
|
||||
dartType.isNull) {
|
||||
return AbstractBool.True;
|
||||
}
|
||||
if (dartType is TypeVariableType || dartType is FunctionTypeVariable) {
|
||||
return AbstractBool.Maybe;
|
||||
}
|
||||
if (dartType is LegacyType) {
|
||||
DartType baseType = dartType.baseType;
|
||||
if (baseType is NeverType) return AbstractBool.True;
|
||||
if (baseType is TypeVariableType || baseType is FunctionTypeVariable) {
|
||||
if (useNullSafety) {
|
||||
if (expressionIsNull.isDefinitelyTrue) {
|
||||
if (dartType.isObject) return AbstractBool.False;
|
||||
if (closedWorld.dartTypes.isTopType(dartType) ||
|
||||
dartType is NullableType ||
|
||||
dartType.isNull) {
|
||||
return AbstractBool.True;
|
||||
}
|
||||
if (dartType is TypeVariableType || dartType is FunctionTypeVariable) {
|
||||
return AbstractBool.Maybe;
|
||||
}
|
||||
if (dartType is LegacyType) {
|
||||
DartType baseType = dartType.baseType;
|
||||
if (baseType is NeverType) return AbstractBool.True;
|
||||
if (baseType is TypeVariableType || baseType is FunctionTypeVariable) {
|
||||
return AbstractBool.Maybe;
|
||||
}
|
||||
}
|
||||
return AbstractBool.False;
|
||||
} else if (expressionIsNull.isPotentiallyTrue) {
|
||||
if (dartType.isObject) return AbstractBool.Maybe;
|
||||
}
|
||||
return AbstractBool.False;
|
||||
}
|
||||
|
||||
if (checkedAbstractValue.isPrecise &&
|
||||
|
||||
@@ -1887,10 +1887,6 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
||||
if (typeInput is HLoadType) {
|
||||
TypeExpressionRecipe recipe = typeInput.typeExpression;
|
||||
DartType dartType = recipe.type;
|
||||
if (_closedWorld.dartTypes.isTopType(dartType)) {
|
||||
return _graph.addConstantBool(true, _closedWorld);
|
||||
}
|
||||
|
||||
IsTestSpecialization specialization =
|
||||
SpecializedChecks.findIsTestSpecialization(
|
||||
dartType, _graph, _closedWorld);
|
||||
|
||||
Reference in New Issue
Block a user