Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/elements/modelx.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart |
| index 1ea7a23e8d21d4eccf6346b944dabd76a0547fcc..5df2219b9480441cd18ad1ae805ce9ae893a37b7 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart |
| @@ -317,6 +317,7 @@ class ErroneousElementX extends ElementX implements ErroneousElement { |
| get origin => unsupported(); |
| get defaultImplementation => unsupported(); |
| + bool get isRedirection => unsupported(); |
| bool get isPatched => unsupported(); |
| bool get isPatch => unsupported(); |
| @@ -1093,6 +1094,34 @@ class FunctionSignatureX implements FunctionSignature { |
| } |
| int get parameterCount => requiredParameterCount + optionalParameterCount; |
| + |
| + /** |
| + * Check whether a function with this signature can be used instead of a |
| + * function with signature [signature] without causing a `noSuchMethod` |
| + * exception/call. |
| + */ |
| + bool isCompatibleWith(FunctionSignature signature) { |
| + if (optionalParametersAreNamed != signature.optionalParametersAreNamed) { |
| + return false; |
| + } |
| + if (optionalParametersAreNamed) { |
| + if (requiredParameterCount != signature.requiredParameterCount) { |
| + return false; |
| + } |
| + for (Element namedParameter in signature.orderedOptionalParameters) { |
|
ngeoffray
2013/05/30 11:57:23
I don't think you need the ordered version.
karlklose
2013/05/30 12:24:41
Yes, changed to optionalParameters.
|
| + if (!orderedOptionalParameters.contains(namedParameter)) { |
| + return false; |
| + } |
| + } |
| + } else { |
| + if (requiredParameterCount > signature.requiredParameterCount || |
|
ngeoffray
2013/05/30 11:57:23
Please add a comment how it is ok to have more par
karlklose
2013/05/30 12:24:41
Done.
|
| + requiredParameterCount < signature.parameterCount || |
| + parameterCount < signature.parameterCount) { |
| + return false; |
| + } |
| + } |
| + return true; |
| + } |
| } |
| class FunctionElementX extends ElementX implements FunctionElement { |
| @@ -1152,6 +1181,8 @@ class FunctionElementX extends ElementX implements FunctionElement { |
| bool get isPatched => patch != null; |
| bool get isPatch => origin != null; |
| + bool get isRedirection => defaultImplementation != this; |
| + |
| FunctionElement get redirectionTarget { |
| if (this == defaultImplementation) return this; |
| var target = defaultImplementation; |