Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 86845ca

Browse files
joshualittcommit-bot@chromium.org
authored andcommitted
[dart2js] Remove nullability before calculating impact.
Change-Id: I8e3d3ee9f99261daad70cf9464083b2c548e89c9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137843 Commit-Queue: Joshua Litt <joshualitt@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
1 parent e687b62 commit 86845ca

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

pkg/compiler/lib/src/js_backend/impact_transformer.dart

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
185185
break;
186186
case TypeUseKind.TYPE_LITERAL:
187187
_customElementsResolutionAnalysis.registerTypeLiteral(type);
188-
if (type is TypeVariableType) {
189-
TypeVariableType typeVariable = type;
188+
var typeWithoutNullability = type.withoutNullability;
189+
if (typeWithoutNullability is TypeVariableType) {
190+
TypeVariableType typeVariable = typeWithoutNullability;
190191
Entity typeDeclaration = typeVariable.element.typeDeclaration;
191192
if (typeDeclaration is ClassEntity) {
192193
_rtiNeedBuilder
@@ -331,21 +332,23 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
331332

332333
registerImpact(_impacts.typeCheck);
333334

334-
if (!_dartTypes.treatAsRawType(type) ||
335-
type.containsTypeVariables ||
336-
type is FunctionType) {
335+
var typeWithoutNullability = type.withoutNullability;
336+
if (!_dartTypes.treatAsRawType(typeWithoutNullability) ||
337+
typeWithoutNullability.containsTypeVariables ||
338+
typeWithoutNullability is FunctionType) {
337339
registerImpact(_impacts.genericTypeCheck);
338-
if (type is TypeVariableType) {
340+
if (typeWithoutNullability is TypeVariableType) {
339341
registerImpact(_impacts.typeVariableTypeCheck);
340342
}
341343
}
342-
if (type is FunctionType) {
344+
if (typeWithoutNullability is FunctionType) {
343345
registerImpact(_impacts.functionTypeCheck);
344346
}
345-
if (type is InterfaceType && _nativeBasicData.isNativeClass(type.element)) {
347+
if (typeWithoutNullability is InterfaceType &&
348+
_nativeBasicData.isNativeClass(typeWithoutNullability.element)) {
346349
registerImpact(_impacts.nativeTypeCheck);
347350
}
348-
if (type is FutureOrType) {
351+
if (typeWithoutNullability is FutureOrType) {
349352
registerImpact(_impacts.futureOrTypeCheck);
350353
}
351354
}
@@ -377,16 +380,20 @@ class CodegenImpactTransformer {
377380
this._rtiChecksBuilder,
378381
this._nativeEmitter);
379382

383+
DartTypes get _dartTypes => _closedWorld.dartTypes;
384+
380385
void onIsCheckForCodegen(DartType type, TransformedWorldImpact transformed) {
381-
if (type is DynamicType) return;
382-
if (type is VoidType) return;
386+
if (_dartTypes.isTopType(type)) return;
387+
383388
_impacts.typeCheck.registerImpact(transformed, _elementEnvironment);
384389

385-
if (!_closedWorld.dartTypes.treatAsRawType(type) ||
386-
type.containsTypeVariables) {
390+
var typeWithoutNullability = type.withoutNullability;
391+
if (!_dartTypes.treatAsRawType(typeWithoutNullability) ||
392+
typeWithoutNullability.containsTypeVariables) {
387393
_impacts.genericIsCheck.registerImpact(transformed, _elementEnvironment);
388394
}
389-
if (type is InterfaceType && _nativeData.isNativeClass(type.element)) {
395+
if (typeWithoutNullability is InterfaceType &&
396+
_nativeData.isNativeClass(typeWithoutNullability.element)) {
390397
// We will neeed to add the "$is" and "$as" properties on the
391398
// JavaScript object prototype, so we make sure
392399
// [:defineProperty:] is compiled.

0 commit comments

Comments
 (0)