Skip to content

Commit bb71c3e

Browse files
fishythefishcommit-bot@chromium.org
authored andcommitted
[dart2js] Ensure type check metadata is generated for types
that otherwise only appear in substitutions. Change-Id: I187975ef7c65b841c54de115da2b3084d3f1a00e Fixes: #32004 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123550 Commit-Queue: Mayank Patke <fishythefish@google.com> Reviewed-by: Stephen Adams <sra@google.com>
1 parent 6f5aee9 commit bb71c3e

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ abstract class RuntimeTypesSubstitutionsMixin
133133

134134
/// Compute the required type checks and substitutions for the given
135135
/// instantiated and checked classes.
136+
// TODO(fishythefish): Unify type checks and substitutions once old RTI is
137+
// removed.
136138
TypeChecks _computeChecks(Map<ClassEntity, ClassUse> classUseMap) {
137139
// Run through the combination of instantiated and checked
138140
// arguments and record all combination where the element of a checked
@@ -297,9 +299,17 @@ abstract class RuntimeTypesSubstitutionsMixin
297299
} else {
298300
// We need a non-trivial substitution function for
299301
// [checkedClass].
300-
checks.add(new TypeCheck(
301-
checkedClass, computeSubstitution(cls, checkedClass),
302-
needsIs: false));
302+
Substitution substitution =
303+
computeSubstitution(cls, checkedClass);
304+
checks.add(
305+
new TypeCheck(checkedClass, substitution, needsIs: false));
306+
307+
assert(substitution != null);
308+
for (DartType argument in substitution.arguments) {
309+
if (argument is InterfaceType) {
310+
computeChecks(argument.element);
311+
}
312+
}
303313
}
304314
}
305315
} else {
@@ -312,9 +322,17 @@ abstract class RuntimeTypesSubstitutionsMixin
312322
} else {
313323
// We need a non-trivial substitution function for
314324
// [checkedClass].
315-
checks.add(new TypeCheck(
316-
checkedClass, computeSubstitution(cls, checkedClass),
317-
needsIs: needsIs));
325+
Substitution substitution =
326+
computeSubstitution(cls, checkedClass);
327+
checks.add(
328+
new TypeCheck(checkedClass, substitution, needsIs: needsIs));
329+
330+
assert(substitution != null);
331+
for (DartType argument in substitution.arguments) {
332+
if (argument is InterfaceType) {
333+
computeChecks(argument.element);
334+
}
335+
}
318336
}
319337
}
320338
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2019, 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+
import "package:expect/expect.dart";
6+
7+
class A {}
8+
9+
class B {}
10+
11+
class C extends A implements B {}
12+
13+
class Base<T> {}
14+
15+
class Sub implements Base<C> {}
16+
17+
void main() {
18+
Expect.subtype<Sub, Base<A>>();
19+
Expect.subtype<Sub, Base<B>>();
20+
}

0 commit comments

Comments
 (0)