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

Unified Diff: tests/language_2/function_type/test_generator.dart

Issue 2998003002: Revert "fix #30462, update function_type tests to understand covariant generics" (Closed)
Patch Set: Created 3 years, 4 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: tests/language_2/function_type/test_generator.dart
diff --git a/tests/language_2/function_type/test_generator.dart b/tests/language_2/function_type/test_generator.dart
index 03892090708f3548817d6955e0dc0f41b68ec787..c2c95cbd7d24903e11e2348d0c30e4cc79c43824 100644
--- a/tests/language_2/function_type/test_generator.dart
+++ b/tests/language_2/function_type/test_generator.dart
@@ -27,19 +27,8 @@ abstract class TypeLike implements Printable {
/// Prints `this` as valid Dart code for a Type.
void writeType(StringBuffer buffer);
- /// Whether this type uses T in some way.
+ /// Whether this instance uses T in some way.
bool get usesT;
-
- /// Whether this type uses T in a return (covariant) position.
- ///
- /// For example: `T`, `List<T>`, `T Function()`, or `Function(Function(T))`.
- bool get returnsT;
-
- /// Whether this type uses T in a parameter (contravariant) position.
- ///
- /// For example, `Function(T)`, `Function(List<T>)`, or
- /// `Function(T Function())`.
- bool get takesT;
}
/// Provides a unique integer for every parameter in a function.
@@ -48,7 +37,7 @@ int parameterNameCounter = 0;
/// Whether `T` should be replaced with `int`.
bool shouldReplaceTWithInt = false;
-class Parameter implements TypeLike {
+class Parameter implements Printable {
final TypeLike type;
final String name;
@@ -102,9 +91,7 @@ class Parameter implements TypeLike {
return ((name.hashCode * 37) ^ type.hashCode) & 0xFFFFFFFF;
}
- bool get usesT => type?.usesT ?? false;
- bool get takesT => type?.takesT ?? false;
- bool get returnsT => type?.returnsT ?? false;
+ bool get usesT => type?.usesT == true;
}
class GenericParameter implements TypeLike {
@@ -144,9 +131,9 @@ class GenericParameter implements TypeLike {
return ((name.hashCode * 23) ^ bound.hashCode) & 0xFFFFFFFF;
}
- bool get usesT => bound?.usesT ?? false;
- bool get takesT => bound?.takesT ?? false;
- bool get returnsT => bound?.returnsT ?? false;
+ bool get usesT {
+ return bound?.usesT == true;
+ }
}
void _describeList(StringBuffer buffer, List<Printable> list) {
@@ -306,25 +293,9 @@ class FunctionType implements TypeLike {
}
bool get usesT {
- return (returnType?.usesT ?? false) ||
+ return returnType?.usesT == true ||
[generic, required, optional, named].any(_listUsesT);
}
-
- bool get returnsT {
- return (returnType?.returnsT ?? false) ||
- [generic, required, optional, named]
- .any((l) => l?.any((p) => p.takesT) ?? false);
- }
-
- bool get takesT {
- return (returnType?.takesT ?? false) ||
- [generic, required, optional, named]
- .any((l) => l?.any((p) => p.returnsT) ?? false);
- }
-
- bool get reifiedTypeUsesT {
- return returnType?.usesT ?? returnsT;
- }
}
class NominalType implements TypeLike {
@@ -365,10 +336,6 @@ class NominalType implements TypeLike {
}
bool get usesT => name == "T" || _listUsesT(generic);
-
- bool get returnsT => name == "T" || generic?.any((t) => t.returnsT) ?? false;
-
- bool get takesT => generic?.any((t) => t.takesT) ?? false;
}
List<FunctionType> buildFunctionTypes() {
@@ -676,12 +643,11 @@ final TYPEDEF_T_TESTS_TEMPLATE = """
Expect.throws(() { #localName = confuse(#staticFunName); });
}
if (tIsInt || tIsBool) {
- Expect.equals(#isIntValue, #methodFunName is #typeName<int>);
- Expect.equals(#isBoolValue, #methodFunName is #typeName<bool>);
- Expect.equals(#isIntValue, confuse(#methodFunName) is #typeName<int>);
- Expect.equals(#isBoolValue, confuse(#methodFunName) is #typeName<bool>);
- }
-""";
+ Expect.equals(tIsInt, #methodFunName is #typeName<int>);
+ Expect.equals(tIsBool, #methodFunName is #typeName<bool>);
+ Expect.equals(tIsInt, confuse(#methodFunName) is #typeName<int>);
+ Expect.equals(tIsBool, confuse(#methodFunName) is #typeName<bool>);
+ }""";
final TEST_METHOD_FOOTER = " }";
@@ -711,9 +677,6 @@ String createMethodFunCode(FunctionType type, int id) {
}
String createTestMethodFunCode(FunctionType type, String typeCode, int id) {
- var tIsInt = type.reifiedTypeUsesT ? 'tIsInt' : 'true';
- var tIsBool = type.reifiedTypeUsesT ? 'tIsBool' : 'true';
-
String fillTemplate(String template, int id) {
var result = template
.replaceAll("#typeName", createTypeName(id))
@@ -722,9 +685,7 @@ String createTestMethodFunCode(FunctionType type, String typeCode, int id) {
.replaceAll("#fieldName", createFieldName(id))
.replaceAll("#localName", createLocalName(id))
.replaceAll("#testName", createTestName(id))
- .replaceAll("#typeCode", typeCode)
- .replaceAll("#isIntValue", tIsInt)
- .replaceAll("#isBoolValue", tIsBool);
+ .replaceAll("#typeCode", typeCode);
assert(!result.contains("#"));
return result;
}
« no previous file with comments | « tests/language_2/function_type/function_type9_test.dart ('k') | tests/language_2/language_2_dartdevc.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698