Skip to content

Commit

Permalink
[dart2js] New RTI: Don't try to instantiate a null function.
Browse files Browse the repository at this point in the history
Change-Id: I6532fb138343e8fe01b3773b3ef6693e52b1b312
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118364
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
  • Loading branch information
fishythefish authored and commit-bot@chromium.org committed Sep 20, 2019
1 parent e2adba8 commit ad52d12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sdk/lib/_internal/js_runtime/lib/rti.dart
Expand Up @@ -363,6 +363,11 @@ Rti evalInInstance(instance, String recipe) {
@pragma('dart2js:noInline')
Rti instantiatedGenericFunctionType(
Rti genericFunctionRti, Rti instantiationRti) {
// If --lax-runtime-type-to-string is enabled and we never check the function
// type, then the function won't have a signature, so its RTI will be null. In
// this case, there is nothing to instantiate, so we return `null` and the
// instantiation appears to be an interface type instead.
if (genericFunctionRti == null) return null;
var bounds = Rti._getGenericFunctionBounds(genericFunctionRti);
var typeArguments = Rti._getInterfaceTypeArguments(instantiationRti);
assert(_Utils.arrayLength(bounds) == _Utils.arrayLength(typeArguments));
Expand Down
5 changes: 5 additions & 0 deletions sdk_nnbd/lib/_internal/js_runtime/lib/rti.dart
Expand Up @@ -365,6 +365,11 @@ Rti evalInInstance(instance, String recipe) {
@pragma('dart2js:noInline')
Rti instantiatedGenericFunctionType(
Rti genericFunctionRti, Rti instantiationRti) {
// If --lax-runtime-type-to-string is enabled and we never check the function
// type, then the function won't have a signature, so its RTI will be null. In
// this case, there is nothing to instantiate, so we return `null` and the
// instantiation appears to be an interface type instead.
if (genericFunctionRti == null) return null;
var bounds = Rti._getGenericFunctionBounds(genericFunctionRti);
var typeArguments = Rti._getInterfaceTypeArguments(instantiationRti);
assert(_Utils.arrayLength(bounds) == _Utils.arrayLength(typeArguments));
Expand Down

0 comments on commit ad52d12

Please sign in to comment.