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

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 1648063002: Implement the spec's notion of LUB for function types. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix passing test. Created 4 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
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/type.dart
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 0f8ec27422f1043550d33383de72ccce8ae0200f..24e06a6d26a27b50d3c924d0619b8bbc2e92df6c 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -409,6 +409,14 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
}
@override
+ List<String> get normalParameterNames {
+ return baseParameters
+ .where((parameter) => parameter.parameterKind == ParameterKind.REQUIRED)
+ .map((parameter) => parameter.name)
+ .toList();
+ }
+
+ @override
List<DartType> get optionalParameterTypes {
List<ParameterElement> parameters = baseParameters;
if (parameters.length == 0) {
@@ -434,6 +442,15 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
}
@override
+ List<String> get optionalParameterNames {
+ return baseParameters
+ .where(
+ (parameter) => parameter.parameterKind == ParameterKind.POSITIONAL)
+ .map((parameter) => parameter.name)
+ .toList();
+ }
+
+ @override
List<ParameterElement> get parameters {
List<ParameterElement> baseParameters = this.baseParameters;
// no parameters, quick return
@@ -1029,19 +1046,6 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
}
/**
- * Compute the least upper bound of types [f] and [g], both of which are
- * known to be function types.
- *
- * In the event that f and g have different numbers of required parameters,
- * `null` is returned, in which case the least upper bound is the interface
- * type `Function`.
- */
- static FunctionType computeLeastUpperBound(FunctionType f, FunctionType g) {
- // TODO(paulberry): implement this.
- return null;
- }
-
- /**
* Return `true` if all of the name/type pairs in the first map ([firstTypes])
* are equal to the corresponding name/type pairs in the second map
* ([secondTypes]). The maps are expected to iterate over their entries in the
@@ -1941,7 +1945,8 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
* If there is a single type which is at least as specific as all of the
* types in [types], return it. Otherwise return `null`.
*/
- static DartType _findMostSpecificType(List<DartType> types, TypeSystem typeSystem) {
+ static DartType _findMostSpecificType(
+ List<DartType> types, TypeSystem typeSystem) {
// The << relation ("more specific than") is a partial ordering on types,
// so to find the most specific type of a set, we keep a bucket of the most
// specific types seen so far such that no type in the bucket is more
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698