Skip to content

Commit b5d2400

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
Always include members of Null in subtype access.
Change-Id: I8e7fa2d418b9dd948b17b385b6d8e8e266582239 Reviewed-on: https://dart-review.googlesource.com/c/86566 Reviewed-by: Sigmund Cherem <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent 4191437 commit b5d2400

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/compiler/lib/src/universe/resolution_world_builder.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,11 @@ class ResolutionWorldBuilderImpl extends WorldBuilderBase
989989
return _classHierarchyBuilder.isInheritedInThisClass(
990990
memberHoldingClass, type);
991991
case ClassRelation.subtype:
992+
if (memberHoldingClass == _commonElements.nullClass ||
993+
memberHoldingClass == _commonElements.jsNullClass) {
994+
// Members of `Null` and `JSNull` are always potential targets.
995+
return true;
996+
}
992997
return _classHierarchyBuilder.isInheritedInSubtypeOf(
993998
memberHoldingClass, type);
994999
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Regression test for DartPad issue 881.
6+
7+
void main() {
8+
String v = null;
9+
print('${v.hashCode}');
10+
// Makes sure that [v] is not effectively final, so that we don't infer the
11+
// static type from the initializer.
12+
v = '';
13+
}

0 commit comments

Comments
 (0)