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

Commit ef3b9cf

Browse files
committed
Initial support for f-bound quantification patterns
This doesn't fix all issues (see remaining broken test), but it unblocks angular. [email protected] Review URL: https://codereview.chromium.org/1431403002 .
1 parent 7dc5564 commit ef3b9cf

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

lib/src/codegen/js_codegen.dart

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,14 +566,39 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
566566
[genericName, typeParams, body, name]);
567567
}
568568

569+
final _hasDeferredSupertype = new HashSet<ClassElement>();
570+
571+
bool _deferIfNeeded(DartType type, ClassElement current) {
572+
if (type is ParameterizedType) {
573+
var typeArguments = type.typeArguments;
574+
for (var typeArg in typeArguments) {
575+
var typeElement = typeArg.element;
576+
// FIXME(vsm): This does not track mutual recursive dependences.
577+
if (current == typeElement || _deferIfNeeded(typeArg, current)) {
578+
return true;
579+
}
580+
}
581+
}
582+
return false;
583+
}
584+
569585
JS.Expression _classHeritage(ClassElement element) {
570586
var type = element.type;
571587
if (type.isObject) return null;
572588

573589
// Assume we can load eagerly, until proven otherwise.
574590
_loader.startTopLevel(element);
575591

576-
JS.Expression heritage = _emitTypeName(type.superclass);
592+
// Find the super type
593+
JS.Expression heritage;
594+
var supertype = type.superclass;
595+
if (_deferIfNeeded(supertype, element)) {
596+
// Fall back to raw type.
597+
supertype = fillDynamicTypeArgs(supertype.element.type, rules.provider);
598+
_hasDeferredSupertype.add(element);
599+
}
600+
heritage = _emitTypeName(supertype);
601+
577602
if (type.mixins.isNotEmpty) {
578603
var mixins = type.mixins.map(_emitTypeName).toList();
579604
mixins.insert(0, heritage);
@@ -701,6 +726,12 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
701726
[classElem.name, _propertyName(jsPeerName)]));
702727
}
703728

729+
// Deferred Superclass
730+
if (_hasDeferredSupertype.contains(classElem)) {
731+
body.add(js.statement('#.prototype.__proto__ = #.prototype;',
732+
[name, _emitTypeName(classElem.type.superclass)]));
733+
}
734+
704735
// Interfaces
705736
if (classElem.interfaces.isNotEmpty) {
706737
body.add(js.statement('#[dart.implements] = () => #;', [

test/browser/language_tests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@
103103
'external_test_10_multi',
104104
'external_test_13_multi',
105105
'external_test_20_multi',
106-
'f_bounded_equality_test',
107-
'f_bounded_quantification2_test',
108106
'f_bounded_quantification3_test',
109107
'factory_type_parameter_test',
110108
'fast_method_extraction_test',

0 commit comments

Comments
 (0)