| Index: pkg/compiler/lib/src/dart_types.dart
|
| diff --git a/pkg/compiler/lib/src/dart_types.dart b/pkg/compiler/lib/src/dart_types.dart
|
| index 52621387adf97e00dfe993db4103cdecc56fe05d..41ce1e548b7ad659bd26a6e11651d39323e56bae 100644
|
| --- a/pkg/compiler/lib/src/dart_types.dart
|
| +++ b/pkg/compiler/lib/src/dart_types.dart
|
| @@ -7,18 +7,13 @@ library dart_types;
|
| import 'dart:math' show min;
|
|
|
| import 'common.dart';
|
| -import 'common/resolution.dart' show
|
| - Resolution;
|
| +import 'common/resolution.dart' show Resolution;
|
| import 'core_types.dart';
|
| -import 'elements/modelx.dart' show
|
| - LibraryElementX,
|
| - TypeDeclarationElementX,
|
| - TypedefElementX;
|
| +import 'elements/modelx.dart'
|
| + show LibraryElementX, TypeDeclarationElementX, TypedefElementX;
|
| import 'elements/elements.dart';
|
| -import 'ordered_typeset.dart' show
|
| - OrderedTypeSet;
|
| -import 'util/util.dart' show
|
| - equalElements;
|
| +import 'ordered_typeset.dart' show OrderedTypeSet;
|
| +import 'util/util.dart' show equalElements;
|
|
|
| enum TypeKind {
|
| FUNCTION,
|
| @@ -79,7 +74,6 @@ abstract class DartType {
|
| // TODO(johnniwinther): Maybe move this to [TypedefType].
|
| void computeUnaliased(Resolution resolution) {}
|
|
|
| -
|
| /// Returns the unaliased type of this type.
|
| ///
|
| /// The unaliased type of a typedef'd type is the unaliased type to which its
|
| @@ -165,8 +159,8 @@ abstract class DartType {
|
|
|
| void visitChildren(DartTypeVisitor visitor, var argument) {}
|
|
|
| - static void visitList(List<DartType> types,
|
| - DartTypeVisitor visitor, var argument) {
|
| + static void visitList(
|
| + List<DartType> types, DartTypeVisitor visitor, var argument) {
|
| for (DartType type in types) {
|
| type.accept(visitor, argument);
|
| }
|
| @@ -234,7 +228,7 @@ class TypeVariableType extends DartType {
|
| int get hashCode => 17 * element.hashCode;
|
|
|
| bool operator ==(other) {
|
| - if (other is !TypeVariableType) return false;
|
| + if (other is! TypeVariableType) return false;
|
| return identical(other.element, element);
|
| }
|
|
|
| @@ -306,7 +300,7 @@ class MalformedType extends DartType {
|
| static int nextHash = 43765;
|
|
|
| MalformedType(this.element, this.userProvidedBadType,
|
| - [this.typeArguments = null]);
|
| + [this.typeArguments = null]);
|
|
|
| TypeKind get kind => TypeKind.MALFORMED_TYPE;
|
|
|
| @@ -348,21 +342,21 @@ abstract class GenericType extends DartType {
|
| final TypeDeclarationElement element;
|
| final List<DartType> typeArguments;
|
|
|
| - GenericType(TypeDeclarationElement element,
|
| - this.typeArguments,
|
| - {bool checkTypeArgumentCount: true})
|
| + GenericType(TypeDeclarationElement element, this.typeArguments,
|
| + {bool checkTypeArgumentCount: true})
|
| : this.element = element {
|
| assert(invariant(CURRENT_ELEMENT_SPANNABLE, element != null,
|
| message: "Missing element for generic type."));
|
| assert(invariant(element, () {
|
| - if (!checkTypeArgumentCount) return true;
|
| - if (element is TypeDeclarationElementX) {
|
| - return element.thisTypeCache == null ||
|
| - typeArguments.length == element.typeVariables.length;
|
| - }
|
| - return true;
|
| - }, message: () => 'Invalid type argument count on ${element.thisType}. '
|
| - 'Provided type arguments: $typeArguments.'));
|
| + if (!checkTypeArgumentCount) return true;
|
| + if (element is TypeDeclarationElementX) {
|
| + return element.thisTypeCache == null ||
|
| + typeArguments.length == element.typeVariables.length;
|
| + }
|
| + return true;
|
| + },
|
| + message: () => 'Invalid type argument count on ${element.thisType}. '
|
| + 'Provided type arguments: $typeArguments.'));
|
| }
|
|
|
| /// Creates a new instance of this type using the provided type arguments.
|
| @@ -422,10 +416,10 @@ abstract class GenericType extends DartType {
|
| }
|
|
|
| bool operator ==(other) {
|
| - if (other is !GenericType) return false;
|
| - return kind == other.kind
|
| - && element == other.element
|
| - && equalElements(typeArguments, other.typeArguments);
|
| + if (other is! GenericType) return false;
|
| + return kind == other.kind &&
|
| + element == other.element &&
|
| + equalElements(typeArguments, other.typeArguments);
|
| }
|
|
|
| /// Returns `true` if the declaration of this type has type variables.
|
| @@ -448,13 +442,12 @@ class InterfaceType extends GenericType {
|
| int _hashCode;
|
|
|
| InterfaceType(ClassElement element,
|
| - [List<DartType> typeArguments = const <DartType>[]])
|
| + [List<DartType> typeArguments = const <DartType>[]])
|
| : super(element, typeArguments) {
|
| assert(invariant(element, element.isDeclaration));
|
| }
|
|
|
| - InterfaceType.forUserProvidedBadType(
|
| - ClassElement element,
|
| + InterfaceType.forUserProvidedBadType(ClassElement element,
|
| [List<DartType> typeArguments = const <DartType>[]])
|
| : super(element, typeArguments, checkTypeArgumentCount: false);
|
|
|
| @@ -481,9 +474,8 @@ class InterfaceType extends GenericType {
|
| if (element == other) return this;
|
| InterfaceType supertype = element.asInstanceOf(other);
|
| if (supertype != null) {
|
| - List<DartType> arguments = Types.substTypes(supertype.typeArguments,
|
| - typeArguments,
|
| - element.typeVariables);
|
| + List<DartType> arguments = Types.substTypes(
|
| + supertype.typeArguments, typeArguments, element.typeVariables);
|
| return new InterfaceType(supertype.element, arguments);
|
| }
|
| return null;
|
| @@ -530,8 +522,7 @@ class InterfaceType extends GenericType {
|
| class BadInterfaceType extends InterfaceType {
|
| final InterfaceType userProvidedBadType;
|
|
|
| - BadInterfaceType(ClassElement element,
|
| - InterfaceType this.userProvidedBadType)
|
| + BadInterfaceType(ClassElement element, InterfaceType this.userProvidedBadType)
|
| : super(element, element.rawType.typeArguments);
|
|
|
| String toString() {
|
| @@ -539,7 +530,6 @@ class BadInterfaceType extends InterfaceType {
|
| }
|
| }
|
|
|
| -
|
| /**
|
| * Special subclass of [TypedefType] used for generic typedef types created
|
| * with the wrong number of type arguments.
|
| @@ -549,8 +539,7 @@ class BadInterfaceType extends InterfaceType {
|
| class BadTypedefType extends TypedefType {
|
| final TypedefType userProvidedBadType;
|
|
|
| - BadTypedefType(TypedefElement element,
|
| - TypedefType this.userProvidedBadType)
|
| + BadTypedefType(TypedefElement element, TypedefType this.userProvidedBadType)
|
| : super(element, element.rawType.typeArguments);
|
|
|
| String toString() {
|
| @@ -575,39 +564,36 @@ class FunctionType extends DartType {
|
| */
|
| final List<DartType> namedParameterTypes;
|
|
|
| - factory FunctionType(
|
| - FunctionTypedElement element,
|
| + factory FunctionType(FunctionTypedElement element,
|
| [DartType returnType = const DynamicType(),
|
| - List<DartType> parameterTypes = const <DartType>[],
|
| - List<DartType> optionalParameterTypes = const <DartType>[],
|
| - List<String> namedParameters = const <String>[],
|
| - List<DartType> namedParameterTypes = const <DartType>[]]) {
|
| + List<DartType> parameterTypes = const <DartType>[],
|
| + List<DartType> optionalParameterTypes = const <DartType>[],
|
| + List<String> namedParameters = const <String>[],
|
| + List<DartType> namedParameterTypes = const <DartType>[]]) {
|
| assert(invariant(CURRENT_ELEMENT_SPANNABLE, element != null));
|
| assert(invariant(element, element.isDeclaration));
|
| - return new FunctionType.internal(element,
|
| - returnType, parameterTypes, optionalParameterTypes,
|
| - namedParameters, namedParameterTypes);
|
| + return new FunctionType.internal(element, returnType, parameterTypes,
|
| + optionalParameterTypes, namedParameters, namedParameterTypes);
|
| }
|
|
|
| factory FunctionType.synthesized(
|
| [DartType returnType = const DynamicType(),
|
| - List<DartType> parameterTypes = const <DartType>[],
|
| - List<DartType> optionalParameterTypes = const <DartType>[],
|
| - List<String> namedParameters = const <String>[],
|
| - List<DartType> namedParameterTypes = const <DartType>[]]) {
|
| - return new FunctionType.internal(null,
|
| - returnType, parameterTypes, optionalParameterTypes,
|
| - namedParameters, namedParameterTypes);
|
| + List<DartType> parameterTypes = const <DartType>[],
|
| + List<DartType> optionalParameterTypes = const <DartType>[],
|
| + List<String> namedParameters = const <String>[],
|
| + List<DartType> namedParameterTypes = const <DartType>[]]) {
|
| + return new FunctionType.internal(null, returnType, parameterTypes,
|
| + optionalParameterTypes, namedParameters, namedParameterTypes);
|
| }
|
|
|
| FunctionType.internal(FunctionTypedElement this.element,
|
| - [DartType this.returnType = const DynamicType(),
|
| - this.parameterTypes = const <DartType>[],
|
| - this.optionalParameterTypes = const <DartType>[],
|
| - this.namedParameters = const <String>[],
|
| - this.namedParameterTypes = const <DartType>[]]) {
|
| - assert(invariant(CURRENT_ELEMENT_SPANNABLE,
|
| - element == null || element.isDeclaration));
|
| + [DartType this.returnType = const DynamicType(),
|
| + this.parameterTypes = const <DartType>[],
|
| + this.optionalParameterTypes = const <DartType>[],
|
| + this.namedParameters = const <String>[],
|
| + this.namedParameterTypes = const <DartType>[]]) {
|
| + assert(invariant(
|
| + CURRENT_ELEMENT_SPANNABLE, element == null || element.isDeclaration));
|
| // Assert that optional and named parameters are not used at the same time.
|
| assert(optionalParameterTypes.isEmpty || namedParameterTypes.isEmpty);
|
| assert(namedParameters.length == namedParameterTypes.length);
|
| @@ -640,18 +626,19 @@ class FunctionType extends DartType {
|
| Types.substTypes(namedParameterTypes, arguments, parameters);
|
| if (!changed &&
|
| (!identical(parameterTypes, newParameterTypes) ||
|
| - !identical(optionalParameterTypes, newOptionalParameterTypes) ||
|
| - !identical(namedParameterTypes, newNamedParameterTypes))) {
|
| + !identical(optionalParameterTypes, newOptionalParameterTypes) ||
|
| + !identical(namedParameterTypes, newNamedParameterTypes))) {
|
| changed = true;
|
| }
|
| if (changed) {
|
| // Create a new type only if necessary.
|
| - return new FunctionType.internal(element,
|
| - newReturnType,
|
| - newParameterTypes,
|
| - newOptionalParameterTypes,
|
| - namedParameters,
|
| - newNamedParameterTypes);
|
| + return new FunctionType.internal(
|
| + element,
|
| + newReturnType,
|
| + newParameterTypes,
|
| + newOptionalParameterTypes,
|
| + namedParameters,
|
| + newNamedParameterTypes);
|
| }
|
| return this;
|
| }
|
| @@ -687,10 +674,10 @@ class FunctionType extends DartType {
|
| }
|
|
|
| void visitChildren(DartTypeVisitor visitor, var argument) {
|
| - returnType.accept(visitor, argument);
|
| - DartType.visitList(parameterTypes, visitor, argument);
|
| - DartType.visitList(optionalParameterTypes, visitor, argument);
|
| - DartType.visitList(namedParameterTypes, visitor, argument);
|
| + returnType.accept(visitor, argument);
|
| + DartType.visitList(parameterTypes, visitor, argument);
|
| + DartType.visitList(optionalParameterTypes, visitor, argument);
|
| + DartType.visitList(namedParameterTypes, visitor, argument);
|
| }
|
|
|
| String toString() {
|
| @@ -719,7 +706,7 @@ class FunctionType extends DartType {
|
| }
|
| sb.write(namedParameterTypes[i]);
|
| sb.write(' ');
|
| - sb.write(namedParameters[i]);
|
| + sb.write(namedParameters[i]);
|
| first = false;
|
| }
|
| sb.write('}');
|
| @@ -734,23 +721,23 @@ class FunctionType extends DartType {
|
|
|
| int get hashCode {
|
| int hash = 3 * returnType.hashCode;
|
| - for (DartType parameter in parameterTypes) {
|
| + for (DartType parameter in parameterTypes) {
|
| hash = 17 * hash + 5 * parameter.hashCode;
|
| }
|
| - for (DartType parameter in optionalParameterTypes) {
|
| + for (DartType parameter in optionalParameterTypes) {
|
| hash = 19 * hash + 7 * parameter.hashCode;
|
| }
|
| - for (String name in namedParameters) {
|
| + for (String name in namedParameters) {
|
| hash = 23 * hash + 11 * name.hashCode;
|
| }
|
| - for (DartType parameter in namedParameterTypes) {
|
| + for (DartType parameter in namedParameterTypes) {
|
| hash = 29 * hash + 13 * parameter.hashCode;
|
| }
|
| return hash;
|
| }
|
|
|
| bool operator ==(other) {
|
| - if (other is !FunctionType) return false;
|
| + if (other is! FunctionType) return false;
|
| return returnType == other.returnType &&
|
| equalElements(parameterTypes, other.parameterTypes) &&
|
| equalElements(optionalParameterTypes, other.optionalParameterTypes) &&
|
| @@ -763,12 +750,11 @@ class TypedefType extends GenericType {
|
| DartType _unaliased;
|
|
|
| TypedefType(TypedefElement element,
|
| - [List<DartType> typeArguments = const <DartType>[]])
|
| + [List<DartType> typeArguments = const <DartType>[]])
|
| : super(element, typeArguments);
|
|
|
| TypedefType.forUserProvidedBadType(TypedefElement element,
|
| - [List<DartType> typeArguments =
|
| - const <DartType>[]])
|
| + [List<DartType> typeArguments = const <DartType>[]])
|
| : super(element, typeArguments, checkTypeArgumentCount: false);
|
|
|
| TypedefElement get element => super.element;
|
| @@ -900,8 +886,7 @@ abstract class BaseDartTypeVisitor<R, A> extends DartTypeVisitor<R, A> {
|
| R visitType(DartType type, A argument);
|
|
|
| @override
|
| - R visitVoidType(VoidType type, A argument) =>
|
| - visitType(type, argument);
|
| + R visitVoidType(VoidType type, A argument) => visitType(type, argument);
|
|
|
| @override
|
| R visitTypeVariableType(TypeVariableType type, A argument) =>
|
| @@ -919,8 +904,7 @@ abstract class BaseDartTypeVisitor<R, A> extends DartTypeVisitor<R, A> {
|
| R visitStatementType(StatementType type, A argument) =>
|
| visitType(type, argument);
|
|
|
| - R visitGenericType(GenericType type, A argument) =>
|
| - visitType(type, argument);
|
| + R visitGenericType(GenericType type, A argument) => visitType(type, argument);
|
|
|
| @override
|
| R visitInterfaceType(InterfaceType type, A argument) =>
|
| @@ -931,8 +915,7 @@ abstract class BaseDartTypeVisitor<R, A> extends DartTypeVisitor<R, A> {
|
| visitGenericType(type, argument);
|
|
|
| @override
|
| - R visitDynamicType(DynamicType type, A argument) =>
|
| - visitType(type, argument);
|
| + R visitDynamicType(DynamicType type, A argument) => visitType(type, argument);
|
| }
|
|
|
| /**
|
| @@ -968,7 +951,6 @@ abstract class AbstractTypeRelation
|
| bool visitMalformedType(MalformedType t, DartType s) => true;
|
|
|
| bool visitInterfaceType(InterfaceType t, DartType s) {
|
| -
|
| // TODO(johnniwinther): Currently needed since literal types like int,
|
| // double, bool etc. might not have been resolved yet.
|
| t.element.ensureResolved(resolution);
|
| @@ -997,7 +979,7 @@ abstract class AbstractTypeRelation
|
| if (s == coreTypes.functionType) {
|
| return true;
|
| }
|
| - if (s is !FunctionType) return false;
|
| + if (s is! FunctionType) return false;
|
| FunctionType tf = t;
|
| FunctionType sf = s;
|
| if (invalidFunctionReturnTypes(tf.returnType, sf.returnType)) {
|
| @@ -1036,7 +1018,7 @@ abstract class AbstractTypeRelation
|
| return false;
|
| }
|
| if (!sf.namedParameters.isEmpty) {
|
| - // We must have [: len(t.p) == len(s.p) :].
|
| + // We must have [: len(t.p) == len(s.p) :].
|
| if (sNotEmpty) {
|
| return false;
|
| }
|
| @@ -1166,7 +1148,6 @@ class MoreSpecificVisitor extends AbstractTypeRelation {
|
| * Type visitor that determines the subtype relation two types.
|
| */
|
| class SubtypeVisitor extends MoreSpecificVisitor {
|
| -
|
| SubtypeVisitor(Resolution resolution) : super(resolution);
|
|
|
| bool isSubtype(DartType t, DartType s) {
|
| @@ -1211,10 +1192,8 @@ class SubtypeVisitor extends MoreSpecificVisitor {
|
| * substitute for the bound of [typeVariable]. [bound] holds the bound against
|
| * which [typeArgument] should be checked.
|
| */
|
| -typedef void CheckTypeVariableBound(GenericType type,
|
| - DartType typeArgument,
|
| - TypeVariableType typeVariable,
|
| - DartType bound);
|
| +typedef void CheckTypeVariableBound(GenericType type, DartType typeArgument,
|
| + TypeVariableType typeVariable, DartType bound);
|
|
|
| /// Basic interface for the Dart type system.
|
| abstract class DartTypes {
|
| @@ -1327,8 +1306,8 @@ class Types implements DartTypes {
|
| * declared on [element]. Calls [checkTypeVariableBound] on each type
|
| * argument and bound.
|
| */
|
| - void checkTypeVariableBounds(GenericType type,
|
| - CheckTypeVariableBound checkTypeVariableBound) {
|
| + void checkTypeVariableBounds(
|
| + GenericType type, CheckTypeVariableBound checkTypeVariableBound) {
|
| TypeDeclarationElement element = type.element;
|
| List<DartType> typeArguments = type.typeArguments;
|
| List<DartType> typeVariables = element.typeVariables;
|
| @@ -1348,8 +1327,7 @@ class Types implements DartTypes {
|
| * instead of a newly created list.
|
| */
|
| static List<DartType> substTypes(List<DartType> types,
|
| - List<DartType> arguments,
|
| - List<DartType> parameters) {
|
| + List<DartType> arguments, List<DartType> parameters) {
|
| bool changed = false;
|
| List<DartType> result = new List<DartType>.generate(types.length, (index) {
|
| DartType type = types[index];
|
| @@ -1409,9 +1387,7 @@ class Types implements DartTypes {
|
| return 1;
|
| }
|
| bool isDefinedByDeclaration(DartType type) {
|
| - return type.isInterfaceType ||
|
| - type.isTypedef ||
|
| - type.isTypeVariable;
|
| + return type.isInterfaceType || type.isTypedef || type.isTypeVariable;
|
| }
|
|
|
| if (isDefinedByDeclaration(a)) {
|
| @@ -1428,7 +1404,7 @@ class Types implements DartTypes {
|
| return -1;
|
| } else {
|
| return compareList((a as GenericType).typeArguments,
|
| - (b as GenericType).typeArguments);
|
| + (b as GenericType).typeArguments);
|
| }
|
| }
|
| } else {
|
| @@ -1449,8 +1425,8 @@ class Types implements DartTypes {
|
| if (result != 0) return result;
|
| result = compareList(aFunc.parameterTypes, bFunc.parameterTypes);
|
| if (result != 0) return result;
|
| - result = compareList(aFunc.optionalParameterTypes,
|
| - bFunc.optionalParameterTypes);
|
| + result = compareList(
|
| + aFunc.optionalParameterTypes, bFunc.optionalParameterTypes);
|
| if (result != 0) return result;
|
| // TODO(karlklose): reuse [compareList].
|
| Iterator<String> aNames = aFunc.namedParameters.iterator;
|
| @@ -1466,8 +1442,8 @@ class Types implements DartTypes {
|
| // [bNames] is longer that [aNames] => a < b.
|
| return -1;
|
| }
|
| - return compareList(aFunc.namedParameterTypes,
|
| - bFunc.namedParameterTypes);
|
| + return compareList(
|
| + aFunc.namedParameterTypes, bFunc.namedParameterTypes);
|
| } else {
|
| // [b] is a malformed or statement type => a < b.
|
| return -1;
|
| @@ -1487,8 +1463,8 @@ class Types implements DartTypes {
|
| // [a] is a malformed type => a < b.
|
| return -1;
|
| }
|
| - assert (a.isMalformed);
|
| - assert (b.isMalformed);
|
| + assert(a.isMalformed);
|
| + assert(b.isMalformed);
|
| // TODO(johnniwinther): Can we do this better?
|
| return Elements.compareByPosition(a.element, b.element);
|
| }
|
| @@ -1511,9 +1487,8 @@ class Types implements DartTypes {
|
| }
|
|
|
| /// Computes the least upper bound of two interface types [a] and [b].
|
| - InterfaceType computeLeastUpperBoundInterfaces(InterfaceType a,
|
| - InterfaceType b) {
|
| -
|
| + InterfaceType computeLeastUpperBoundInterfaces(
|
| + InterfaceType a, InterfaceType b) {
|
| /// Returns the set of supertypes of [type] at depth [depth].
|
| Set<DartType> getSupertypesAtDepth(InterfaceType type, int depth) {
|
| OrderedTypeSet types = type.element.allSupertypesAndSelf;
|
| @@ -1543,8 +1518,8 @@ class Types implements DartTypes {
|
|
|
| /// Computes the least upper bound of the types in the longest prefix of [a]
|
| /// and [b].
|
| - List<DartType> computeLeastUpperBoundsTypes(List<DartType> a,
|
| - List<DartType> b) {
|
| + List<DartType> computeLeastUpperBoundsTypes(
|
| + List<DartType> a, List<DartType> b) {
|
| if (a.isEmpty || b.isEmpty) return const <DartType>[];
|
| int prefixLength = min(a.length, b.length);
|
| List<DartType> types = new List<DartType>(prefixLength);
|
| @@ -1565,17 +1540,15 @@ class Types implements DartTypes {
|
| /// bound of the longest common prefix of the optional parameters of [a] and
|
| /// [b], and the named parameters are the least upper bound of those common to
|
| /// [a] and [b].
|
| - DartType computeLeastUpperBoundFunctionTypes(FunctionType a,
|
| - FunctionType b) {
|
| + DartType computeLeastUpperBoundFunctionTypes(FunctionType a, FunctionType b) {
|
| if (a.parameterTypes.length != b.parameterTypes.length) {
|
| return coreTypes.functionType;
|
| }
|
| DartType returnType = computeLeastUpperBound(a.returnType, b.returnType);
|
| List<DartType> parameterTypes =
|
| computeLeastUpperBoundsTypes(a.parameterTypes, b.parameterTypes);
|
| - List<DartType> optionalParameterTypes =
|
| - computeLeastUpperBoundsTypes(a.optionalParameterTypes,
|
| - b.optionalParameterTypes);
|
| + List<DartType> optionalParameterTypes = computeLeastUpperBoundsTypes(
|
| + a.optionalParameterTypes, b.optionalParameterTypes);
|
| List<String> namedParameters = <String>[];
|
| List<String> aNamedParameters = a.namedParameters;
|
| List<String> bNamedParameters = b.namedParameters;
|
| @@ -1584,8 +1557,8 @@ class Types implements DartTypes {
|
| List<DartType> bNamedParameterTypes = b.namedParameterTypes;
|
| int aIndex = 0;
|
| int bIndex = 0;
|
| - while (aIndex < aNamedParameters.length &&
|
| - bIndex < bNamedParameters.length) {
|
| + while (
|
| + aIndex < aNamedParameters.length && bIndex < bNamedParameters.length) {
|
| String aNamedParameter = aNamedParameters[aIndex];
|
| String bNamedParameter = bNamedParameters[bIndex];
|
| int result = aNamedParameter.compareTo(bNamedParameter);
|
| @@ -1601,18 +1574,15 @@ class Types implements DartTypes {
|
| bIndex++;
|
| }
|
| }
|
| - return new FunctionType.synthesized(
|
| - returnType,
|
| - parameterTypes, optionalParameterTypes,
|
| - namedParameters, namedParameterTypes);
|
| + return new FunctionType.synthesized(returnType, parameterTypes,
|
| + optionalParameterTypes, namedParameters, namedParameterTypes);
|
| }
|
|
|
| /// Computes the least upper bound of two types of which at least one is a
|
| /// type variable. The least upper bound of a type variable is defined in
|
| /// terms of its bound, but to ensure reflexivity we need to check for common
|
| /// bounds transitively.
|
| - DartType computeLeastUpperBoundTypeVariableTypes(DartType a,
|
| - DartType b) {
|
| + DartType computeLeastUpperBoundTypeVariableTypes(DartType a, DartType b) {
|
| Set<DartType> typeVariableBounds = new Set<DartType>();
|
| while (a.isTypeVariable) {
|
| if (a == b) return a;
|
| @@ -1688,9 +1658,7 @@ class Types implements DartTypes {
|
| /// unaliasedBound(U) = unaliasedBound(Baz) = ()->dynamic
|
| /// unaliasedBound(X) = unaliasedBound(Y) = `Object`
|
| ///
|
| - static DartType computeUnaliasedBound(
|
| - Resolution resolution,
|
| - DartType type) {
|
| + static DartType computeUnaliasedBound(Resolution resolution, DartType type) {
|
| DartType originalType = type;
|
| while (type.isTypeVariable) {
|
| TypeVariableType variable = type;
|
| @@ -1734,8 +1702,7 @@ class Types implements DartTypes {
|
| /// used to lookup the existence and type of `foo`.
|
| ///
|
| static InterfaceType computeInterfaceType(
|
| - Resolution resolution,
|
| - DartType type) {
|
| + Resolution resolution, DartType type) {
|
| type = computeUnaliasedBound(resolution, type);
|
| if (type.treatAsDynamic) {
|
| return null;
|
| @@ -1783,8 +1750,8 @@ class MoreSpecificSubtypeVisitor extends BaseDartTypeVisitor<bool, DartType> {
|
| ///
|
| /// Note that this computation is a heuristic. It does not find a suggestion
|
| /// in all possible cases.
|
| - InterfaceType computeMoreSpecific(ClassElement element,
|
| - InterfaceType supertype) {
|
| + InterfaceType computeMoreSpecific(
|
| + ClassElement element, InterfaceType supertype) {
|
| InterfaceType supertypeInstance =
|
| element.thisType.asInstanceOf(supertype.element);
|
| if (supertypeInstance == null) return null;
|
| @@ -1815,16 +1782,14 @@ class MoreSpecificSubtypeVisitor extends BaseDartTypeVisitor<bool, DartType> {
|
| }
|
|
|
| bool visitTypeVariableType(TypeVariableType type, DartType argument) {
|
| - DartType constraint =
|
| - types.getMostSpecific(constraintMap[type], argument);
|
| + DartType constraint = types.getMostSpecific(constraintMap[type], argument);
|
| constraintMap[type] = constraint;
|
| return constraint != null;
|
| }
|
|
|
| bool visitFunctionType(FunctionType type, DartType argument) {
|
| if (argument is FunctionType) {
|
| - if (type.parameterTypes.length !=
|
| - argument.parameterTypes.length) {
|
| + if (type.parameterTypes.length != argument.parameterTypes.length) {
|
| return false;
|
| }
|
| if (type.optionalParameterTypes.length !=
|
| @@ -1839,8 +1804,8 @@ class MoreSpecificSubtypeVisitor extends BaseDartTypeVisitor<bool, DartType> {
|
| if (visitTypes(type.parameterTypes, argument.parameterTypes)) {
|
| return false;
|
| }
|
| - if (visitTypes(type.optionalParameterTypes,
|
| - argument.optionalParameterTypes)) {
|
| + if (visitTypes(
|
| + type.optionalParameterTypes, argument.optionalParameterTypes)) {
|
| return false;
|
| }
|
| return visitTypes(type.namedParameterTypes, argument.namedParameterTypes);
|
| @@ -1964,4 +1929,3 @@ class TypeDeclarationFormatter extends BaseDartTypeVisitor<dynamic, String> {
|
| sb.write(')');
|
| }
|
| }
|
| -
|
|
|