Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2641543003: Use "Object" as the reified type of covariant override parameters. (Closed)
Patch Set: Move getReifiedType() to MethodElement. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index afabcf3a6cb464103b5cce1d8cd97a446732f367..02bd29718523b196c607d07c7b70ca7357a87520 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -188,7 +188,7 @@ class CodeGenerator extends GeneralizingAstVisitor
_buildUnit = unit;
_libraryRoot = _buildUnit.libraryRoot;
if (!_libraryRoot.endsWith(separator)) {
- _libraryRoot = '$_libraryRoot${separator}';
+ _libraryRoot += separator;
}
var module = _emitModule(compilationUnits);
@@ -1806,7 +1806,6 @@ class CodeGenerator extends GeneralizingAstVisitor
Function lookup;
List<JS.Property> tMember;
- JS.Expression type;
if (node.isGetter) {
lookup = classElem.lookUpInheritedConcreteGetter;
tMember = node.isStatic ? tStaticGetters : tInstanceGetters;
@@ -1819,16 +1818,25 @@ class CodeGenerator extends GeneralizingAstVisitor
tMember = node.isStatic ? tStaticMethods : tInstanceMethods;
}
- type = _emitAnnotatedFunctionType(element.type, node.metadata,
+ // Swap in "Object" over parameter types that are covariant overrides.
+ var objectType = context.typeProvider.objectType;
+ var reifiedType = element is MethodElement
+ ? element.getReifiedType(objectType)
+ : element.type;
+ var type = _emitAnnotatedFunctionType(reifiedType, node.metadata,
parameters: node.parameters?.parameters,
nameType: options.hoistSignatureTypes,
hoistType: options.hoistSignatureTypes,
definite: true);
+ // Don't add redundant signatures for inherited unchanged methods.
var inheritedElement = lookup(name, currentLibrary);
- if (inheritedElement != null && inheritedElement.type == element.type) {
+ if (inheritedElement != null &&
+ (inheritedElement is! MethodElement ||
Leaf 2017/01/18 01:51:45 Is this right? You're not checking that the type
Bob Nystrom 2017/01/18 21:42:52 Oops, fixed. Sorry.
+ inheritedElement.getReifiedType(objectType) == reifiedType)) {
continue;
}
+
var memberName = _declareMemberName(element);
var property = new JS.Property(memberName, type);
tMember.add(property);
@@ -2908,7 +2916,7 @@ class CodeGenerator extends GeneralizingAstVisitor
lowerTypedef: lowerTypedef,
nameType: nameType,
hoistType: hoistType);
- var helper = (definite) ? 'definiteFunctionType' : 'functionType';
+ var helper = definite ? 'definiteFunctionType' : 'functionType';
var fullType = _callHelper('${helper}(#)', [parts]);
if (!nameType) return fullType;
return _typeTable.nameType(type, fullType,
@@ -2943,6 +2951,7 @@ class CodeGenerator extends GeneralizingAstVisitor
var namedTypes = type.namedParameterTypes;
var rt =
_emitType(type.returnType, nameType: nameType, hoistType: hoistType);
+
var ra = _emitTypeNames(parameterTypes, parameters,
nameType: nameType, hoistType: hoistType);

Powered by Google App Engine
This is Rietveld 408576698