diff --git a/pkg/compiler/lib/src/ir/visitors.dart b/pkg/compiler/lib/src/ir/visitors.dart index 8557c88e7dc..f07422e9329 100644 --- a/pkg/compiler/lib/src/ir/visitors.dart +++ b/pkg/compiler/lib/src/ir/visitors.dart @@ -218,6 +218,11 @@ class DartTypeConverter extends ir.DartTypeVisitor { DartType defaultDartType(ir.DartType node) { throw UnsupportedError('Unsupported type $node (${node.runtimeType})'); } + + @override + DartType visitTypedefType(ir.TypedefType node) { + throw UnsupportedError('Unsupported type $node (${node.runtimeType})'); + } } class ConstantValuefier extends ir.ComputeOnceConstantVisitor { diff --git a/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart b/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart index d4055a8c0fd..8b34fce83f0 100644 --- a/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart +++ b/pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart @@ -255,6 +255,10 @@ class _TypeRecipeVisitor extends DartTypeVisitor { String defaultDartType(DartType node) => throw UnimplementedError('Unknown DartType: $node'); + @override + String visitInvalidType(DartType node) => + throw UnimplementedError('Unknown DartType: $node'); + @override String visitDynamicType(DynamicType node) => Recipe.pushDynamicString; diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart index 5323341999d..d7a415e5953 100644 --- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart +++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart @@ -24,6 +24,7 @@ import 'package:kernel/ast.dart'; import 'package:kernel/class_hierarchy.dart'; import 'package:kernel/core_types.dart'; import 'package:kernel/src/const_canonical_type.dart'; +import 'package:kernel/src/find_type_visitor.dart'; import 'package:kernel/src/legacy_erasure.dart'; import 'package:kernel/src/norm.dart'; import 'package:kernel/src/printer.dart' @@ -6215,88 +6216,25 @@ class SimpleErrorReporter implements ErrorReporter { } bool isInstantiated(DartType type) { - return type.accept(new IsInstantiatedVisitor()); + return !type.accept(new HasUninstantiatedVisitor()); } -class IsInstantiatedVisitor implements DartTypeVisitor { +class HasUninstantiatedVisitor extends FindTypeVisitor { final _availableVariables = new Set(); - bool isInstantiated(DartType type) { - return type.accept(this); - } - - @override - bool defaultDartType(DartType node) { - // Probably unreachable. - throw 'A visitor method seems to be unimplemented!'; - } - - @override - bool visitInvalidType(InvalidType node) => true; - - @override - bool visitDynamicType(DynamicType node) => true; - - @override - bool visitVoidType(VoidType node) => true; - - @override - bool visitNullType(NullType node) => true; - @override bool visitTypeParameterType(TypeParameterType node) { - return _availableVariables.contains(node.parameter); - } - - @override - bool visitInterfaceType(InterfaceType node) { - return node.typeArguments - .every((DartType typeArgument) => typeArgument.accept(this)); - } - - @override - bool visitFutureOrType(FutureOrType node) { - return node.typeArgument.accept(this); + return !_availableVariables.contains(node.parameter); } @override bool visitFunctionType(FunctionType node) { final List parameters = node.typeParameters; _availableVariables.addAll(parameters); - final bool result = node.typeParameters - .every((p) => p.bound.accept(this) && p.defaultType.accept(this)) && - node.returnType.accept(this) && - node.positionalParameters.every((p) => p.accept(this)) && - node.namedParameters.every((p) => p.type.accept(this)); + bool result = super.visitFunctionType(node); _availableVariables.removeAll(parameters); return result; } - - @override - bool visitTypedefType(TypedefType node) { - // Probably unreachable. - return node.unalias.accept(this); - } - - @override - bool visitNeverType(NeverType node) => true; - - @override - bool visitRecordType(RecordType node) { - return node.positional.every((p) => p.accept(this)) && - node.named.every((p) => p.type.accept(this)); - } - - @override - bool visitExtensionType(ExtensionType node) { - return node.typeArguments - .every((DartType typeArgument) => typeArgument.accept(this)); - } - - @override - bool visitIntersectionType(IntersectionType node) { - return node.left.accept(this) && node.right.accept(this); - } } bool _isFormalParameter(VariableDeclaration variable) { diff --git a/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart b/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart index 7424604ccbb..966244be20c 100644 --- a/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart +++ b/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart @@ -4,6 +4,8 @@ import 'package:kernel/ast.dart'; +import 'package:kernel/src/find_type_visitor.dart'; + import 'package:kernel/type_algebra.dart' show containsTypeVariable; import 'package:kernel/util/graph.dart' show Graph, computeStrongComponents; @@ -1334,86 +1336,11 @@ bool hasAnyTypeVariables(DartType type) { /// Don't use this directly, use [hasAnyTypeVariables] instead. But don't use /// that either. // TODO(ahe): Remove this class. -class TypeVariableSearch implements DartTypeVisitor { +class TypeVariableSearch extends FindTypeVisitor { const TypeVariableSearch(); - @override - bool defaultDartType(DartType node) => throw "unsupported"; - - bool anyTypeVariables(List types) { - for (DartType type in types) { - if (type.accept(this)) return true; - } - return false; - } - - @override - bool visitInvalidType(InvalidType node) => false; - - @override - bool visitDynamicType(DynamicType node) => false; - - @override - bool visitVoidType(VoidType node) => false; - - @override - bool visitNeverType(NeverType node) => false; - - @override - bool visitNullType(NullType node) => false; - - @override - bool visitInterfaceType(InterfaceType node) { - return anyTypeVariables(node.typeArguments); - } - - @override - bool visitExtensionType(ExtensionType node) { - return anyTypeVariables(node.typeArguments); - } - - @override - bool visitFutureOrType(FutureOrType node) { - return node.typeArgument.accept(this); - } - - @override - bool visitFunctionType(FunctionType node) { - if (anyTypeVariables(node.positionalParameters)) return true; - for (TypeParameter variable in node.typeParameters) { - if (variable.bound.accept(this)) return true; - } - for (NamedType type in node.namedParameters) { - if (type.type.accept(this)) return true; - } - return false; - } - @override bool visitTypeParameterType(TypeParameterType node) => true; - - @override - bool visitIntersectionType(IntersectionType node) { - // The left-hand side of an [IntersectionType] is always a - // [TypeParameterType]. - // ignore: unnecessary_type_check - assert(node.left is TypeParameterType); - return true; - } - - @override - bool visitTypedefType(TypedefType node) { - return anyTypeVariables(node.typeArguments); - } - - @override - bool visitRecordType(RecordType node) { - if (anyTypeVariables(node.positional)) return true; - for (NamedType namedType in node.named) { - if (namedType.type.accept(this)) return true; - } - return false; - } } /// A representation of a found non-simplicity issue in bounds diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_results.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_results.dart index 3552ae1ad9c..932a9b8f5b8 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/inference_results.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/inference_results.dart @@ -343,7 +343,7 @@ class ExpressionInferenceResult { ExpressionInferenceResult(this.inferredType, this.expression, {this.postCoercionType = null}) - : assert(isKnown(inferredType)); + : assert(isKnown(inferredType), "$inferredType is not known."); /// The guards used for null-aware access if the expression is part of a /// null-shorting. diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart index 298a707f8ac..5292e033d5e 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart @@ -739,6 +739,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor { DartType contextType, Template template) { Expression errorNode = new AsExpression( expression, + // TODO(johnniwinther): Fix this. // TODO(ahe): The outline phase doesn't correctly remove invalid // uses of type variables, for example, on static members. Once // that has been fixed, we should always be able to use @@ -763,6 +764,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor { {List? context}) { Expression errorNode = new AsExpression( expression, + // TODO(johnniwinther): Fix this. // TODO(ahe): The outline phase doesn't correctly remove invalid // uses of type variables, for example, on static members. Once // that has been fixed, we should always be able to use diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_demotion.dart b/pkg/front_end/lib/src/fasta/type_inference/type_demotion.dart index e2e0472ead7..dc66e0905c2 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_demotion.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_demotion.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE.md file. import 'package:kernel/ast.dart'; +import 'package:kernel/src/find_type_visitor.dart'; import 'package:kernel/src/replacement_visitor.dart'; /// Returns `true` if type contains a promoted type variable. @@ -11,43 +12,9 @@ bool hasPromotedTypeVariable(DartType type) { } /// Visitor that returns `true` if a type contains a promoted type variable. -class _HasPromotedTypeVariableVisitor extends DartTypeVisitor { +class _HasPromotedTypeVariableVisitor extends FindTypeVisitor { const _HasPromotedTypeVariableVisitor(); - @override - bool defaultDartType(DartType node) => false; - - @override - bool visitFunctionType(FunctionType node) { - if (node.returnType.accept(this)) return true; - for (DartType parameterType in node.positionalParameters) { - if (parameterType.accept(this)) return true; - } - for (NamedType namedParameterType in node.namedParameters) { - if (namedParameterType.type.accept(this)) return true; - } - return false; - } - - @override - bool visitInterfaceType(InterfaceType node) { - for (DartType typeArgument in node.typeArguments) { - if (typeArgument.accept(this)) return true; - } - return false; - } - - @override - bool visitTypedefType(TypedefType node) { - for (DartType typeArgument in node.typeArguments) { - if (typeArgument.accept(this)) return true; - } - return false; - } - - @override - bool visitTypeParameterType(TypeParameterType node) => false; - @override bool visitIntersectionType(IntersectionType node) => true; } diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart b/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart index 22f3acbb6fc..a61e9890e78 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart @@ -4,6 +4,7 @@ import 'package:kernel/ast.dart'; import 'package:kernel/src/assumptions.dart'; +import 'package:kernel/src/find_type_visitor.dart'; import 'package:kernel/src/printer.dart'; import 'package:kernel/import_table.dart' show ImportTable; @@ -12,7 +13,7 @@ import 'package:kernel/text/ast_to_text.dart' show Annotator, NameSystem, Printer, globalDebuggingNames; /// Determines whether a type schema contains `?` somewhere inside it. -bool isKnown(DartType schema) => schema.accept(const _IsKnownVisitor()); +bool isKnown(DartType schema) => !schema.accept(const _HasUnknownVisitor()); /// Converts a [DartType] to a string, representing the unknown type as `?`. String typeSchemaToString(DartType schema) { @@ -95,87 +96,10 @@ class UnknownType extends DartType { } } -/// Visitor that computes [isKnown]. -class _IsKnownVisitor implements DartTypeVisitor { - const _IsKnownVisitor(); +/// Visitor used to compute [isKnown]. +class _HasUnknownVisitor extends FindTypeVisitor { + const _HasUnknownVisitor(); @override - bool defaultDartType(DartType node) => node is! UnknownType; - - @override - bool visitDynamicType(DynamicType node) => true; - - @override - bool visitInvalidType(InvalidType node) => true; - - @override - bool visitNeverType(NeverType node) => true; - - @override - bool visitIntersectionType(IntersectionType node) => true; - - @override - bool visitNullType(NullType node) => true; - - @override - bool visitTypeParameterType(TypeParameterType node) => true; - - @override - bool visitVoidType(VoidType node) => true; - - @override - bool visitFunctionType(FunctionType node) { - if (!node.returnType.accept(this)) return false; - for (DartType parameterType in node.positionalParameters) { - if (!parameterType.accept(this)) return false; - } - for (NamedType namedParameterType in node.namedParameters) { - if (!namedParameterType.type.accept(this)) return false; - } - for (TypeParameter typeParameter in node.typeParameters) { - if (!typeParameter.bound.accept(this)) return false; - if (!typeParameter.defaultType.accept(this)) return false; - } - return true; - } - - @override - bool visitInterfaceType(InterfaceType node) { - for (DartType typeArgument in node.typeArguments) { - if (!typeArgument.accept(this)) return false; - } - return true; - } - - @override - bool visitExtensionType(ExtensionType node) { - for (DartType typeArgument in node.typeArguments) { - if (!typeArgument.accept(this)) return false; - } - return true; - } - - @override - bool visitRecordType(RecordType node) { - for (DartType positional in node.positional) { - if (!positional.accept(this)) return false; - } - for (NamedType named in node.named) { - if (!named.type.accept(this)) return false; - } - return true; - } - - @override - bool visitFutureOrType(FutureOrType node) { - return node.typeArgument.accept(this); - } - - @override - bool visitTypedefType(TypedefType node) { - for (DartType typeArgument in node.typeArguments) { - if (!typeArgument.accept(this)) return false; - } - return true; - } + bool defaultDartType(DartType node) => node is UnknownType; } diff --git a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.expect b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.expect index 27c84840f72..7ad3c232843 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.expect @@ -100,7 +100,7 @@ B Function() test17() => DB2.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:42:32: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test17() => DB2.new; // Error. - ^" in #C12 as{TypeError} () → self::B as{TypeError} () → self::B; + ^" in #C12 as{TypeError} Never as{TypeError} Never; static method test18() → () → self::B return #C9; static method test19() → () → self::B @@ -118,7 +118,7 @@ B Function() test23() => DB3.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:49:35: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test23() => DB3.new; // Error. - ^" in #C13 as{TypeError} () → self::B as{TypeError} () → self::B; + ^" in #C13 as{TypeError} Never as{TypeError} Never; static method test24() → () → self::B return #C14; static method main() → dynamic {} diff --git a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.transformed.expect b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.transformed.expect index 82e359a0235..90ee3101a70 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.strong.transformed.expect @@ -100,7 +100,7 @@ B Function() test17() => DB2.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:42:32: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test17() => DB2.new; // Error. - ^" in #C12 as{TypeError} () → self::B; + ^" in #C12 as{TypeError} Never; static method test18() → () → self::B return #C9; static method test19() → () → self::B @@ -118,7 +118,7 @@ B Function() test23() => DB3.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:49:35: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test23() => DB3.new; // Error. - ^" in #C13 as{TypeError} () → self::B; + ^" in #C13 as{TypeError} Never; static method test24() → () → self::B return #C14; static method main() → dynamic {} diff --git a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.expect b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.expect index 8cfb1b4a6dc..8424da86f29 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.expect @@ -100,7 +100,7 @@ B Function() test17() => DB2.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:42:32: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test17() => DB2.new; // Error. - ^" in #C12 as{TypeError} () → self::B as{TypeError} () → self::B; + ^" in #C12 as{TypeError} Never as{TypeError} Never; static method test18() → () → self::B return #C9; static method test19() → () → self::B @@ -118,7 +118,7 @@ B Function() test23() => DB3.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:49:35: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test23() => DB3.new; // Error. - ^" in #C13 as{TypeError} () → self::B as{TypeError} () → self::B; + ^" in #C13 as{TypeError} Never as{TypeError} Never; static method test24() → () → self::B return #C14; static method main() → dynamic {} diff --git a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.modular.expect b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.modular.expect index 8cfb1b4a6dc..8424da86f29 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.modular.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.modular.expect @@ -100,7 +100,7 @@ B Function() test17() => DB2.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:42:32: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test17() => DB2.new; // Error. - ^" in #C12 as{TypeError} () → self::B as{TypeError} () → self::B; + ^" in #C12 as{TypeError} Never as{TypeError} Never; static method test18() → () → self::B return #C9; static method test19() → () → self::B @@ -118,7 +118,7 @@ B Function() test23() => DB3.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:49:35: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test23() => DB3.new; // Error. - ^" in #C13 as{TypeError} () → self::B as{TypeError} () → self::B; + ^" in #C13 as{TypeError} Never as{TypeError} Never; static method test24() → () → self::B return #C14; static method main() → dynamic {} diff --git a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.transformed.expect b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.transformed.expect index f2f30c32e31..61125f38276 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart.weak.transformed.expect @@ -100,7 +100,7 @@ B Function() test17() => DB2.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:42:32: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test17() => DB2.new; // Error. - ^" in #C12 as{TypeError} () → self::B; + ^" in #C12 as{TypeError} Never; static method test18() → () → self::B return #C9; static method test19() → () → self::B @@ -118,7 +118,7 @@ B Function() test23() => DB3.new; // Error. ^" in invalid-expression "pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart:49:35: Error: A value of type 'B Function()' can't be assigned to a variable of type 'B Function()'. - 'B' is from 'pkg/front_end/testcases/constructor_tearoffs/typedef_tearoffs.dart'. B Function() test23() => DB3.new; // Error. - ^" in #C13 as{TypeError} () → self::B; + ^" in #C13 as{TypeError} Never; static method test24() → () → self::B return #C14; static method main() → dynamic {} diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart index 162d4679f51..39daf670a3e 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart @@ -23,14 +23,14 @@ test( List t4b, // Error, void Function(T4) t4c, // Error void Function(List) t4d, // Error - T5 t5a, // Error, - List t5b, // Error, - void Function(T5) t5c, // Error - void Function(List) t5d, // Error - T6 t6a, // Error, - List t6b, // Error, - void Function(T6) t6c, // Error - void Function(List) t6d, // Error + T5 t5a, // Ok, + List t5b, // Ok, + void Function(T5) t5c, // Ok + void Function(List) t5d, // Ok + T6 t6a, // Ok, + List t6b, // Ok, + void Function(T6) t6c, // Ok + void Function(List) t6d, // Ok T7 t7a, // Error, List t7b, // Error, void Function(T7) t7c, // Error @@ -39,6 +39,22 @@ test( List t8b, // Error, void Function(T8) t8c, // Error void Function(List) t8d, // Error + T9 t9a, // Error, + List t9b, // Error, + void Function(T9) t9c, // Error + void Function(List) t9d, // Error + T10 t10a, // Error, + List t10b, // Error, + void Function(T10) t10c, // Error + void Function(List) t10d, // Error + T11 t11a, // Ok, + List t11b, // Ok, + void Function(T11) t11c, // Ok + void Function(List) t11d, // Ok + T12 t12a, // Error, + List t12b, // Error, + void Function(T12) t12c, // Error + void Function(List) t12d, // Error ) { new T4(); // Error []; // Error diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.expect index 1fcd376edc7..3e68c6d5abb 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.expect @@ -66,43 +66,150 @@ library; // void Function(List) t3d, // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:34:3: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// T7 t7a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:35:8: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// List t7b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:36:17: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(T7) t7c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:37:22: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(List) t7d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:42:3: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T9 t9a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:8: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t9b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:17: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T9) t9c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:22: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t9d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:3: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T10 t10a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:8: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t10b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:48:17: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T10) t10c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:49:22: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t10d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:54:3: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T12 t12a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:55:8: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t12b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:56:17: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T12) t12c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:57:22: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t12d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. // - 'List' is from 'dart:core'. // new T7(0); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:7: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:59:7: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // new T4(); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:4: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:60:4: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:18: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:61:18: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:23: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:62:23: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // )>[]; // Error // ^ // +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:64:4: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:65:18: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:66:23: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// )>[]; // Error +// ^ +// import self as self; import "dart:core" as core; import "alias_from_opt_in_lib.dart" as ali; import "org-dartlang-testcase:///alias_from_opt_in_lib.dart"; -static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d) → dynamic { +static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d, (core::List<(T%) → void>, core::int) t9a, core::List<(core::List<(T%) → void>, core::int)> t9b, ((core::List<(T%) → void>, core::int)) → void t9c, (core::List<(core::List<(T%) → void>, core::int)>) → void t9d, ({required a: core::List<(T%) → void>, required b: core::int}) t10a, core::List<({required a: core::List<(T%) → void>, required b: core::int})> t10b, (({required a: core::List<(T%) → void>, required b: core::int})) → void t10c, (core::List<({required a: core::List<(T%) → void>, required b: core::int})>) → void t10d, FutureOr<(T%) → void>t11a, core::List(T%) → void>> t11b, (FutureOr<(T%) → void>) → void t11c, (core::List(T%) → void>>) → void t11d, FutureOr(T%) → void>>t12a, core::List(T%) → void>>> t12b, (FutureOr(T%) → void>>) → void t12c, (core::List(T%) → void>>>) → void t12d) → dynamic { new ali::Class::•<(T%) → void>(); (T%) → void>>[]; <(ali::Class<(T%) → void>) → void>[]; <(core::List(T%) → void>>) → void>[]; - ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. + ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. - 'List' is from 'dart:core'. new T7(0); // Error ^" in 0 as{TypeError} core::List); @@ -116,6 +223,8 @@ library; import self as ali; import "dart:core" as core; +import "dart:async"; + typedef T1 = (T%) → void; typedef T2 = ((T%) → void) → void; typedef T3 = core::List<(T%) → void>; @@ -124,6 +233,10 @@ typedef T5 = ((T%) → void, core::int); typedef T6 = ({required a: (T%) → void, required b: core::int}); typedef T7 = ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */; typedef T8 = (T%) → void = dynamic>(S) → void; +typedef T9 = (core::List<(T%) → void>, core::int); +typedef T10 = ({required a: core::List<(T%) → void>, required b: core::int}); +typedef T11 = FutureOr<(T%) → void>; +typedef T12 = FutureOr(T%) → void>>; class Class extends core::Object { synthetic constructor •() → ali::Class : super core::Object::•() @@ -139,7 +252,7 @@ static inline-class-member method ExtensionType|(core::List it) → ali::ExtensionType /* = core::List */ return ali::ExtensionType|(it); -static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8) → dynamic { +static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8, (core::List<(T%) → void>, core::int) t9, ({required a: core::List<(T%) → void>, required b: core::int}) t10, FutureOr<(T%) → void>t11, FutureOr(T%) → void>>t12) → dynamic { new ali::Class::•<(T%) → void>(); ali::ExtensionType|([]); } diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.transformed.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.transformed.expect index 089d8b0924d..d529ee36ff2 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.strong.transformed.expect @@ -66,43 +66,150 @@ library; // void Function(List) t3d, // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:34:3: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// T7 t7a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:35:8: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// List t7b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:36:17: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(T7) t7c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:37:22: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(List) t7d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:42:3: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T9 t9a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:8: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t9b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:17: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T9) t9c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:22: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t9d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:3: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T10 t10a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:8: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t10b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:48:17: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T10) t10c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:49:22: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t10d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:54:3: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T12 t12a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:55:8: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t12b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:56:17: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T12) t12c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:57:22: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t12d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. // - 'List' is from 'dart:core'. // new T7(0); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:7: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:59:7: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // new T4(); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:4: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:60:4: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:18: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:61:18: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:23: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:62:23: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // )>[]; // Error // ^ // +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:64:4: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:65:18: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:66:23: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// )>[]; // Error +// ^ +// import self as self; import "dart:core" as core; import "alias_from_opt_in_lib.dart" as ali; import "org-dartlang-testcase:///alias_from_opt_in_lib.dart"; -static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d) → dynamic { +static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d, (core::List<(T%) → void>, core::int) t9a, core::List<(core::List<(T%) → void>, core::int)> t9b, ((core::List<(T%) → void>, core::int)) → void t9c, (core::List<(core::List<(T%) → void>, core::int)>) → void t9d, ({required a: core::List<(T%) → void>, required b: core::int}) t10a, core::List<({required a: core::List<(T%) → void>, required b: core::int})> t10b, (({required a: core::List<(T%) → void>, required b: core::int})) → void t10c, (core::List<({required a: core::List<(T%) → void>, required b: core::int})>) → void t10d, FutureOr<(T%) → void>t11a, core::List(T%) → void>> t11b, (FutureOr<(T%) → void>) → void t11c, (core::List(T%) → void>>) → void t11d, FutureOr(T%) → void>>t12a, core::List(T%) → void>>> t12b, (FutureOr(T%) → void>>) → void t12c, (core::List(T%) → void>>>) → void t12d) → dynamic { new ali::Class::•<(T%) → void>(); core::_GrowableList::•(T%) → void>>(0); core::_GrowableList::•<(ali::Class<(T%) → void>) → void>(0); core::_GrowableList::•<(core::List(T%) → void>>) → void>(0); - ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. + ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. - 'List' is from 'dart:core'. new T7(0); // Error ^" in 0 as{TypeError} core::List); @@ -116,6 +223,8 @@ library; import self as ali; import "dart:core" as core; +import "dart:async"; + typedef T1 = (T%) → void; typedef T2 = ((T%) → void) → void; typedef T3 = core::List<(T%) → void>; @@ -124,6 +233,10 @@ typedef T5 = ((T%) → void, core::int); typedef T6 = ({required a: (T%) → void, required b: core::int}); typedef T7 = ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */; typedef T8 = (T%) → void = dynamic>(S) → void; +typedef T9 = (core::List<(T%) → void>, core::int); +typedef T10 = ({required a: core::List<(T%) → void>, required b: core::int}); +typedef T11 = FutureOr<(T%) → void>; +typedef T12 = FutureOr(T%) → void>>; class Class extends core::Object { synthetic constructor •() → ali::Class : super core::Object::•() @@ -139,7 +252,7 @@ static inline-class-member method ExtensionType|(core::List it) → ali::ExtensionType /* = core::List */ return ali::ExtensionType|(it); -static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8) → dynamic { +static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8, (core::List<(T%) → void>, core::int) t9, ({required a: core::List<(T%) → void>, required b: core::int}) t10, FutureOr<(T%) → void>t11, FutureOr(T%) → void>>t12) → dynamic { new ali::Class::•<(T%) → void>(); ali::ExtensionType|(core::_GrowableList::•(0)); } diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline.expect index 5ee3b7b0a05..32147d1ddee 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline.expect @@ -34,5 +34,21 @@ test( List t8b, void Function(T8) t8c, void Function(List) t8d, + T9 t9a, + List t9b, + void Function(T9) t9c, + void Function(List) t9d, + T10 t10a, + List t10b, + void Function(T10) t10c, + void Function(List) t10d, + T11 t11a, + List t11b, + void Function(T11) t11c, + void Function(List) t11d, + T12 t12a, + List t12b, + void Function(T12) t12c, + void Function(List) t12d, ) {} main() {} diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline_modelled.expect index b9f7796c9f6..223377b10b2 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.textual_outline_modelled.expect @@ -35,4 +35,20 @@ test( List t8b, void Function(T8) t8c, void Function(List) t8d, + T9 t9a, + List t9b, + void Function(T9) t9c, + void Function(List) t9d, + T10 t10a, + List t10b, + void Function(T10) t10c, + void Function(List) t10d, + T11 t11a, + List t11b, + void Function(T11) t11c, + void Function(List) t11d, + T12 t12a, + List t12b, + void Function(T12) t12c, + void Function(List) t12d, ) {} diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.expect index 1fcd376edc7..3e68c6d5abb 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.expect @@ -66,43 +66,150 @@ library; // void Function(List) t3d, // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:34:3: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// T7 t7a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:35:8: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// List t7b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:36:17: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(T7) t7c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:37:22: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(List) t7d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:42:3: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T9 t9a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:8: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t9b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:17: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T9) t9c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:22: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t9d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:3: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T10 t10a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:8: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t10b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:48:17: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T10) t10c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:49:22: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t10d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:54:3: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T12 t12a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:55:8: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t12b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:56:17: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T12) t12c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:57:22: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t12d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. // - 'List' is from 'dart:core'. // new T7(0); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:7: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:59:7: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // new T4(); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:4: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:60:4: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:18: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:61:18: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:23: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:62:23: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // )>[]; // Error // ^ // +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:64:4: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:65:18: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:66:23: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// )>[]; // Error +// ^ +// import self as self; import "dart:core" as core; import "alias_from_opt_in_lib.dart" as ali; import "org-dartlang-testcase:///alias_from_opt_in_lib.dart"; -static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d) → dynamic { +static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d, (core::List<(T%) → void>, core::int) t9a, core::List<(core::List<(T%) → void>, core::int)> t9b, ((core::List<(T%) → void>, core::int)) → void t9c, (core::List<(core::List<(T%) → void>, core::int)>) → void t9d, ({required a: core::List<(T%) → void>, required b: core::int}) t10a, core::List<({required a: core::List<(T%) → void>, required b: core::int})> t10b, (({required a: core::List<(T%) → void>, required b: core::int})) → void t10c, (core::List<({required a: core::List<(T%) → void>, required b: core::int})>) → void t10d, FutureOr<(T%) → void>t11a, core::List(T%) → void>> t11b, (FutureOr<(T%) → void>) → void t11c, (core::List(T%) → void>>) → void t11d, FutureOr(T%) → void>>t12a, core::List(T%) → void>>> t12b, (FutureOr(T%) → void>>) → void t12c, (core::List(T%) → void>>>) → void t12d) → dynamic { new ali::Class::•<(T%) → void>(); (T%) → void>>[]; <(ali::Class<(T%) → void>) → void>[]; <(core::List(T%) → void>>) → void>[]; - ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. + ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. - 'List' is from 'dart:core'. new T7(0); // Error ^" in 0 as{TypeError} core::List); @@ -116,6 +223,8 @@ library; import self as ali; import "dart:core" as core; +import "dart:async"; + typedef T1 = (T%) → void; typedef T2 = ((T%) → void) → void; typedef T3 = core::List<(T%) → void>; @@ -124,6 +233,10 @@ typedef T5 = ((T%) → void, core::int); typedef T6 = ({required a: (T%) → void, required b: core::int}); typedef T7 = ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */; typedef T8 = (T%) → void = dynamic>(S) → void; +typedef T9 = (core::List<(T%) → void>, core::int); +typedef T10 = ({required a: core::List<(T%) → void>, required b: core::int}); +typedef T11 = FutureOr<(T%) → void>; +typedef T12 = FutureOr(T%) → void>>; class Class extends core::Object { synthetic constructor •() → ali::Class : super core::Object::•() @@ -139,7 +252,7 @@ static inline-class-member method ExtensionType|(core::List it) → ali::ExtensionType /* = core::List */ return ali::ExtensionType|(it); -static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8) → dynamic { +static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8, (core::List<(T%) → void>, core::int) t9, ({required a: core::List<(T%) → void>, required b: core::int}) t10, FutureOr<(T%) → void>t11, FutureOr(T%) → void>>t12) → dynamic { new ali::Class::•<(T%) → void>(); ali::ExtensionType|([]); } diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.modular.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.modular.expect index 1fcd376edc7..3e68c6d5abb 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.modular.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.modular.expect @@ -66,43 +66,150 @@ library; // void Function(List) t3d, // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:34:3: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// T7 t7a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:35:8: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// List t7b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:36:17: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(T7) t7c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:37:22: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(List) t7d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:42:3: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T9 t9a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:8: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t9b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:17: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T9) t9c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:22: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t9d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:3: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T10 t10a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:8: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t10b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:48:17: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T10) t10c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:49:22: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t10d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:54:3: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T12 t12a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:55:8: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t12b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:56:17: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T12) t12c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:57:22: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t12d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. // - 'List' is from 'dart:core'. // new T7(0); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:7: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:59:7: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // new T4(); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:4: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:60:4: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:18: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:61:18: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:23: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:62:23: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // )>[]; // Error // ^ // +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:64:4: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:65:18: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:66:23: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// )>[]; // Error +// ^ +// import self as self; import "dart:core" as core; import "alias_from_opt_in_lib.dart" as ali; import "org-dartlang-testcase:///alias_from_opt_in_lib.dart"; -static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d) → dynamic { +static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d, (core::List<(T%) → void>, core::int) t9a, core::List<(core::List<(T%) → void>, core::int)> t9b, ((core::List<(T%) → void>, core::int)) → void t9c, (core::List<(core::List<(T%) → void>, core::int)>) → void t9d, ({required a: core::List<(T%) → void>, required b: core::int}) t10a, core::List<({required a: core::List<(T%) → void>, required b: core::int})> t10b, (({required a: core::List<(T%) → void>, required b: core::int})) → void t10c, (core::List<({required a: core::List<(T%) → void>, required b: core::int})>) → void t10d, FutureOr<(T%) → void>t11a, core::List(T%) → void>> t11b, (FutureOr<(T%) → void>) → void t11c, (core::List(T%) → void>>) → void t11d, FutureOr(T%) → void>>t12a, core::List(T%) → void>>> t12b, (FutureOr(T%) → void>>) → void t12c, (core::List(T%) → void>>>) → void t12d) → dynamic { new ali::Class::•<(T%) → void>(); (T%) → void>>[]; <(ali::Class<(T%) → void>) → void>[]; <(core::List(T%) → void>>) → void>[]; - ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. + ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. - 'List' is from 'dart:core'. new T7(0); // Error ^" in 0 as{TypeError} core::List); @@ -116,6 +223,8 @@ library; import self as ali; import "dart:core" as core; +import "dart:async"; + typedef T1 = (T%) → void; typedef T2 = ((T%) → void) → void; typedef T3 = core::List<(T%) → void>; @@ -124,6 +233,10 @@ typedef T5 = ((T%) → void, core::int); typedef T6 = ({required a: (T%) → void, required b: core::int}); typedef T7 = ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */; typedef T8 = (T%) → void = dynamic>(S) → void; +typedef T9 = (core::List<(T%) → void>, core::int); +typedef T10 = ({required a: core::List<(T%) → void>, required b: core::int}); +typedef T11 = FutureOr<(T%) → void>; +typedef T12 = FutureOr(T%) → void>>; class Class extends core::Object { synthetic constructor •() → ali::Class : super core::Object::•() @@ -139,7 +252,7 @@ static inline-class-member method ExtensionType|(core::List it) → ali::ExtensionType /* = core::List */ return ali::ExtensionType|(it); -static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8) → dynamic { +static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8, (core::List<(T%) → void>, core::int) t9, ({required a: core::List<(T%) → void>, required b: core::int}) t10, FutureOr<(T%) → void>t11, FutureOr(T%) → void>>t12) → dynamic { new ali::Class::•<(T%) → void>(); ali::ExtensionType|([]); } diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.outline.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.outline.expect index 28e76dbfeab..f08855c203a 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.outline.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.outline.expect @@ -66,13 +66,105 @@ library; // void Function(List) t3d, // Error // ^ // +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:34:3: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// T7 t7a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:35:8: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// List t7b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:36:17: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(T7) t7c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:37:22: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(List) t7d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:42:3: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T9 t9a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:8: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t9b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:17: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T9) t9c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:22: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t9d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:3: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T10 t10a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:8: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t10b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:48:17: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T10) t10c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:49:22: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t10d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:54:3: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T12 t12a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:55:8: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t12b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:56:17: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T12) t12c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:57:22: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t12d, // Error +// ^ +// import self as self; import "dart:core" as core; import "alias_from_opt_in_lib.dart" as ali; import "org-dartlang-testcase:///alias_from_opt_in_lib.dart"; -static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d) → dynamic +static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d, (core::List<(T%) → void>, core::int) t9a, core::List<(core::List<(T%) → void>, core::int)> t9b, ((core::List<(T%) → void>, core::int)) → void t9c, (core::List<(core::List<(T%) → void>, core::int)>) → void t9d, ({required a: core::List<(T%) → void>, required b: core::int}) t10a, core::List<({required a: core::List<(T%) → void>, required b: core::int})> t10b, (({required a: core::List<(T%) → void>, required b: core::int})) → void t10c, (core::List<({required a: core::List<(T%) → void>, required b: core::int})>) → void t10d, FutureOr<(T%) → void>t11a, core::List(T%) → void>> t11b, (FutureOr<(T%) → void>) → void t11c, (core::List(T%) → void>>) → void t11d, FutureOr(T%) → void>>t12a, core::List(T%) → void>>> t12b, (FutureOr(T%) → void>>) → void t12c, (core::List(T%) → void>>>) → void t12d) → dynamic ; static method main() → dynamic ; @@ -81,6 +173,8 @@ library; import self as ali; import "dart:core" as core; +import "dart:async"; + typedef T1 = (T%) → void; typedef T2 = ((T%) → void) → void; typedef T3 = core::List<(T%) → void>; @@ -89,6 +183,10 @@ typedef T5 = ((T%) → void, core::int); typedef T6 = ({required a: (T%) → void, required b: core::int}); typedef T7 = ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */; typedef T8 = (T%) → void = dynamic>(S) → void; +typedef T9 = (core::List<(T%) → void>, core::int); +typedef T10 = ({required a: core::List<(T%) → void>, required b: core::int}); +typedef T11 = FutureOr<(T%) → void>; +typedef T12 = FutureOr(T%) → void>>; class Class extends core::Object { synthetic constructor •() → ali::Class ; @@ -101,7 +199,7 @@ static inline-class-member method ExtensionType|(core::List it) → ali::ExtensionType /* = core::List */ return ali::ExtensionType|(it); -static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8) → dynamic +static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8, (core::List<(T%) → void>, core::int) t9, ({required a: core::List<(T%) → void>, required b: core::int}) t10, FutureOr<(T%) → void>t11, FutureOr(T%) → void>>t12) → dynamic ; static method _#T4#new#tearOff(T%) → void>() → ali::Class return new ali::Class::•(); diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.transformed.expect b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.transformed.expect index 089d8b0924d..d529ee36ff2 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart.weak.transformed.expect @@ -66,43 +66,150 @@ library; // void Function(List) t3d, // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:34:3: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// T7 t7a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:35:8: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// List t7b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:36:17: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(T7) t7c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:37:22: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// void Function(List) t7d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:42:3: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T9 t9a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:8: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t9b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:17: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T9) t9c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:22: Error: Generic function type '(List(T)>, int)' used as a type argument through typedef 'T9'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t9d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:3: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T10 t10a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:8: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t10b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:48:17: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T10) t10c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:49:22: Error: Generic function type '({List(T)> a, int b})' used as a type argument through typedef 'T10'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t10d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:54:3: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// T12 t12a, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:55:8: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// List t12b, // Error, +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:56:17: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(T12) t12c, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:57:22: Error: Generic function type 'FutureOr(T)>>' used as a type argument through typedef 'T12'. +// - 'List' is from 'dart:core'. +// Try providing a non-generic function type explicitly. +// void Function(List) t12d, // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. // - 'List' is from 'dart:core'. // new T7(0); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:43:7: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:59:7: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // new T4(); // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:44:4: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:60:4: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:45:18: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:61:18: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // []; // Error // ^ // -// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:46:23: Error: Generic function type 'void Function(T)' inferred as a type argument. +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:62:23: Error: Generic function type 'void Function(T)' inferred as a type argument. // Try providing a non-generic function type explicitly. // )>[]; // Error // ^ // +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:64:4: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:65:18: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// []; // Error +// ^ +// +// pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:66:23: Error: Generic function type 'ExtensionType(T)>' used as a type argument through typedef 'T7'. +// Try providing a non-generic function type explicitly. +// )>[]; // Error +// ^ +// import self as self; import "dart:core" as core; import "alias_from_opt_in_lib.dart" as ali; import "org-dartlang-testcase:///alias_from_opt_in_lib.dart"; -static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d) → dynamic { +static method test((T%) → void t1a, core::List<(T%) → void> t1b, ((T%) → void) → void t1c, (core::List<(T%) → void>) → void t1d, ((T%) → void) → void t2a, core::List<((T%) → void) → void> t2b, (((T%) → void) → void) → void t2c, (core::List<((T%) → void) → void>) → void t2d, core::List<(T%) → void> t3a, core::List(T%) → void>> t3b, (core::List<(T%) → void>) → void t3c, (core::List(T%) → void>>) → void t3d, ali::Class<(T%) → void> t4a, core::List(T%) → void>> t4b, (ali::Class<(T%) → void>) → void t4c, (core::List(T%) → void>>) → void t4d, ((T%) → void, core::int) t5a, core::List<((T%) → void, core::int)> t5b, (((T%) → void, core::int)) → void t5c, (core::List<((T%) → void, core::int)>) → void t5d, ({required a: (T%) → void, required b: core::int}) t6a, core::List<({required a: (T%) → void, required b: core::int})> t6b, (({required a: (T%) → void, required b: core::int})) → void t6c, (core::List<({required a: (T%) → void, required b: core::int})>) → void t6d, ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */ t7a, core::List(T%) → void> /* = core::List<(T%) → void> */> t7b, (ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */) → void t7c, (core::List(T%) → void> /* = core::List<(T%) → void> */>) → void t7d, (T%) → void = dynamic>(S) → void t8a, core::List<(T%) → void = dynamic>(S) → void> t8b, ((T%) → void = dynamic>(S) → void) → void t8c, (core::List<(T%) → void = dynamic>(S) → void>) → void t8d, (core::List<(T%) → void>, core::int) t9a, core::List<(core::List<(T%) → void>, core::int)> t9b, ((core::List<(T%) → void>, core::int)) → void t9c, (core::List<(core::List<(T%) → void>, core::int)>) → void t9d, ({required a: core::List<(T%) → void>, required b: core::int}) t10a, core::List<({required a: core::List<(T%) → void>, required b: core::int})> t10b, (({required a: core::List<(T%) → void>, required b: core::int})) → void t10c, (core::List<({required a: core::List<(T%) → void>, required b: core::int})>) → void t10d, FutureOr<(T%) → void>t11a, core::List(T%) → void>> t11b, (FutureOr<(T%) → void>) → void t11c, (core::List(T%) → void>>) → void t11d, FutureOr(T%) → void>>t12a, core::List(T%) → void>>> t12b, (FutureOr(T%) → void>>) → void t12c, (core::List(T%) → void>>>) → void t12d) → dynamic { new ali::Class::•<(T%) → void>(); core::_GrowableList::•(T%) → void>>(0); core::_GrowableList::•<(ali::Class<(T%) → void>) → void>(0); core::_GrowableList::•<(core::List(T%) → void>>) → void>(0); - ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:47:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. + ali::ExtensionType|(invalid-expression "pkg/front_end/testcases/generic_metadata/alias_from_opt_in.dart:63:10: Error: The argument type 'int' can't be assigned to the parameter type 'List'. - 'List' is from 'dart:core'. new T7(0); // Error ^" in 0 as{TypeError} core::List); @@ -116,6 +223,8 @@ library; import self as ali; import "dart:core" as core; +import "dart:async"; + typedef T1 = (T%) → void; typedef T2 = ((T%) → void) → void; typedef T3 = core::List<(T%) → void>; @@ -124,6 +233,10 @@ typedef T5 = ((T%) → void, core::int); typedef T6 = ({required a: (T%) → void, required b: core::int}); typedef T7 = ali::ExtensionType<(T%) → void> /* = core::List<(T%) → void> */; typedef T8 = (T%) → void = dynamic>(S) → void; +typedef T9 = (core::List<(T%) → void>, core::int); +typedef T10 = ({required a: core::List<(T%) → void>, required b: core::int}); +typedef T11 = FutureOr<(T%) → void>; +typedef T12 = FutureOr(T%) → void>>; class Class extends core::Object { synthetic constructor •() → ali::Class : super core::Object::•() @@ -139,7 +252,7 @@ static inline-class-member method ExtensionType|(core::List it) → ali::ExtensionType /* = core::List */ return ali::ExtensionType|(it); -static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8) → dynamic { +static method test((T%) → void t1, (T%) → void t2, core::List<(T%) → void> t3, ((T%) → void, core::int) t5, ({required a: (T%) → void, required b: core::int}) t6, (T%) → void = dynamic>(S) → void t8, (core::List<(T%) → void>, core::int) t9, ({required a: core::List<(T%) → void>, required b: core::int}) t10, FutureOr<(T%) → void>t11, FutureOr(T%) → void>>t12) → dynamic { new ali::Class::•<(T%) → void>(); ali::ExtensionType|(core::_GrowableList::•(0)); } diff --git a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in_lib.dart b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in_lib.dart index 32c78fb5392..19e801c26c1 100644 --- a/pkg/front_end/testcases/generic_metadata/alias_from_opt_in_lib.dart +++ b/pkg/front_end/testcases/generic_metadata/alias_from_opt_in_lib.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:async'; + class Class {} typedef T1 = void Function(T); @@ -12,6 +14,10 @@ typedef T5 = (void Function(T), int); typedef T6 = ({void Function(T) a, int b}); typedef T7 = ExtensionType(T)>; typedef T8 = void Function(T)>(S); +typedef T9 = (List(T)>, int); +typedef T10 = ({List(T)> a, int b}); +typedef T11 = FutureOr(T)>; +typedef T12 = FutureOr(T)>>; extension type ExtensionType(List it) {} @@ -22,6 +28,10 @@ test( T5 t5, // Ok T6 t6, // Ok T8 t8, // Ok + T9 t9, // Ok + T10 t10, // Ok + T11 t11, // Ok + T12 t12, // Ok ) { new T4(); // Ok new T7([]); // Ok diff --git a/pkg/kernel/lib/src/bounds_checks.dart b/pkg/kernel/lib/src/bounds_checks.dart index ffb6a068a25..636cf88d449 100644 --- a/pkg/kernel/lib/src/bounds_checks.dart +++ b/pkg/kernel/lib/src/bounds_checks.dart @@ -2,17 +2,12 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:kernel/src/replacement_visitor.dart'; - import '../ast.dart'; - import '../type_algebra.dart' show Substitution, substitute; - import '../type_environment.dart' show SubtypeCheckMode, TypeEnvironment; - import '../util/graph.dart' show Graph, computeStrongComponents; - import 'legacy_erasure.dart'; +import 'replacement_visitor.dart'; class TypeVariableGraph extends Graph { @override @@ -927,7 +922,6 @@ bool hasGenericFunctionTypeAsTypeArgument(DartType type) { const _HasGenericFunctionTypeAsTypeArgumentVisitor(), false); } -// TODO(johnniwinther): Handle record type and extension type in this visitor. class _HasGenericFunctionTypeAsTypeArgumentVisitor extends DartTypeVisitor1 { const _HasGenericFunctionTypeAsTypeArgumentVisitor(); @@ -940,8 +934,6 @@ class _HasGenericFunctionTypeAsTypeArgumentVisitor if (isTypeArgument && node.typeParameters.isNotEmpty) { return true; } - // TODO(johnniwinther): Should deeply nested generic function types be - // disallowed? if (node.returnType.accept1(this, false)) return true; for (DartType parameterType in node.positionalParameters) { if (parameterType.accept1(this, false)) return true; @@ -949,6 +941,11 @@ class _HasGenericFunctionTypeAsTypeArgumentVisitor for (NamedType namedParameterType in node.namedParameters) { if (namedParameterType.type.accept1(this, false)) return true; } + for (TypeParameter typeParameter in node.typeParameters) { + if (typeParameter.bound.accept1(this, false)) { + return true; + } + } return false; } @@ -967,4 +964,52 @@ class _HasGenericFunctionTypeAsTypeArgumentVisitor } return false; } + + @override + bool visitExtensionType(ExtensionType node, bool isTypeArgument) { + for (DartType typeArgument in node.typeArguments) { + if (typeArgument.accept1(this, true)) return true; + } + return false; + } + + @override + bool visitDynamicType(DynamicType node, bool isTypeArgument) => false; + + @override + bool visitFutureOrType(FutureOrType node, bool isTypeArgument) { + return node.typeArgument.accept1(this, false); + } + + @override + bool visitIntersectionType(IntersectionType node, bool isTypeArgument) { + return node.left.accept1(this, false) || node.right.accept1(this, false); + } + + @override + bool visitInvalidType(InvalidType node, bool isTypeArgument) => false; + + @override + bool visitNeverType(NeverType node, bool isTypeArgument) => false; + + @override + bool visitNullType(NullType node, bool isTypeArgument) => false; + + @override + bool visitRecordType(RecordType node, bool isTypeArgument) { + for (DartType parameterType in node.positional) { + if (parameterType.accept1(this, false)) return true; + } + for (NamedType namedParameterType in node.named) { + if (namedParameterType.type.accept1(this, false)) return true; + } + return false; + } + + @override + bool visitTypeParameterType(TypeParameterType node, bool isTypeArgument) => + false; + + @override + bool visitVoidType(VoidType node, bool isTypeArgument) => false; } diff --git a/pkg/kernel/lib/src/find_type_visitor.dart b/pkg/kernel/lib/src/find_type_visitor.dart new file mode 100644 index 00000000000..20534960833 --- /dev/null +++ b/pkg/kernel/lib/src/find_type_visitor.dart @@ -0,0 +1,91 @@ +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE.md file. + +import '../ast.dart'; + +class FindTypeVisitor implements DartTypeVisitor { + const FindTypeVisitor(); + + @override + bool defaultDartType(DartType node) => false; + + @override + bool visitFunctionType(FunctionType node) { + if (node.returnType.accept(this)) return true; + for (DartType parameterType in node.positionalParameters) { + if (parameterType.accept(this)) return true; + } + for (NamedType namedParameterType in node.namedParameters) { + if (namedParameterType.type.accept(this)) return true; + } + for (TypeParameter parameter in node.typeParameters) { + if (parameter.bound.accept(this)) return true; + if (parameter.defaultType.accept(this)) return true; + } + return false; + } + + @override + bool visitInterfaceType(InterfaceType node) { + for (DartType typeArgument in node.typeArguments) { + if (typeArgument.accept(this)) return true; + } + return false; + } + + @override + bool visitTypedefType(TypedefType node) { + for (DartType typeArgument in node.typeArguments) { + if (typeArgument.accept(this)) return true; + } + return false; + } + + @override + bool visitTypeParameterType(TypeParameterType node) => false; + + @override + bool visitIntersectionType(IntersectionType node) { + return node.left.accept(this) || node.right.accept(this); + } + + @override + bool visitDynamicType(DynamicType node) => false; + + @override + bool visitExtensionType(ExtensionType node) { + for (DartType typeArgument in node.typeArguments) { + if (typeArgument.accept(this)) return true; + } + return false; + } + + @override + bool visitFutureOrType(FutureOrType node) { + return node.typeArgument.accept(this); + } + + @override + bool visitInvalidType(InvalidType node) => false; + + @override + bool visitNeverType(NeverType node) => false; + + @override + bool visitNullType(NullType node) => false; + + @override + bool visitRecordType(RecordType node) { + for (DartType parameterType in node.positional) { + if (parameterType.accept(this)) return true; + } + for (NamedType namedParameterType in node.named) { + if (namedParameterType.type.accept(this)) return true; + } + return false; + } + + @override + bool visitVoidType(VoidType node) => false; +} diff --git a/pkg/kernel/lib/type_algebra.dart b/pkg/kernel/lib/type_algebra.dart index ebe278734cb..0ae614b4796 100644 --- a/pkg/kernel/lib/type_algebra.dart +++ b/pkg/kernel/lib/type_algebra.dart @@ -6,6 +6,7 @@ library kernel.type_algebra; import 'ast.dart'; import 'core_types.dart'; +import 'src/find_type_visitor.dart'; import 'src/replacement_visitor.dart'; /// Returns all free type variables in [type]. @@ -889,7 +890,7 @@ class _DeepTypeSubstitutor extends _InnerTypeSubstitutor { } } -class _OccurrenceVisitor implements DartTypeVisitor { +class _OccurrenceVisitor extends FindTypeVisitor { final Set variables; /// Helper function invoked on unknown implementers of [DartType]. @@ -903,7 +904,7 @@ class _OccurrenceVisitor implements DartTypeVisitor { _OccurrenceVisitor(this.variables, {this.unhandledTypeHandler}); - bool visit(DartType node) => node.accept(this); + bool visit(DartType type) => type.accept(this); bool visitNamedType(NamedType node) { return visit(node.type); @@ -918,37 +919,6 @@ class _OccurrenceVisitor implements DartTypeVisitor { } } - @override - bool visitNeverType(NeverType node) => false; - @override - bool visitNullType(NullType node) => false; - @override - bool visitInvalidType(InvalidType node) => false; - @override - bool visitDynamicType(DynamicType node) => false; - @override - bool visitVoidType(VoidType node) => false; - - @override - bool visitInterfaceType(InterfaceType node) { - return node.typeArguments.any(visit); - } - - @override - bool visitExtensionType(ExtensionType node) { - return node.typeArguments.any(visit); - } - - @override - bool visitFutureOrType(FutureOrType node) { - return visit(node.typeArgument); - } - - @override - bool visitTypedefType(TypedefType node) { - return node.typeArguments.any(visit); - } - @override bool visitFunctionType(FunctionType node) { return node.typeParameters.any(handleTypeParameter) || @@ -957,21 +927,11 @@ class _OccurrenceVisitor implements DartTypeVisitor { visit(node.returnType); } - @override - bool visitRecordType(RecordType node) { - return node.positional.any(visit) || node.named.any(visitNamedType); - } - @override bool visitTypeParameterType(TypeParameterType node) { return variables.contains(node.parameter); } - @override - bool visitIntersectionType(IntersectionType node) { - return visit(node.left) || visit(node.right); - } - bool handleTypeParameter(TypeParameter node) { assert(!variables.contains(node)); if (node.bound.accept(this)) return true; @@ -979,166 +939,48 @@ class _OccurrenceVisitor implements DartTypeVisitor { } } -class _FreeFunctionTypeVariableVisitor implements DartTypeVisitor { +class _FreeFunctionTypeVariableVisitor extends FindTypeVisitor { final Set variables = new Set(); _FreeFunctionTypeVariableVisitor(); bool visit(DartType node) => node.accept(this); - @override - bool defaultDartType(DartType node) { - throw new UnsupportedError("Unsupported type $node (${node.runtimeType})."); - } - - bool visitNamedType(NamedType node) { - return visit(node.type); - } - - @override - bool visitNeverType(NeverType node) => false; - @override - bool visitNullType(NullType node) => false; - @override - bool visitInvalidType(InvalidType node) => false; - @override - bool visitDynamicType(DynamicType node) => false; - @override - bool visitVoidType(VoidType node) => false; - - @override - bool visitInterfaceType(InterfaceType node) { - return node.typeArguments.any(visit); - } - - @override - bool visitExtensionType(ExtensionType node) { - return node.typeArguments.any(visit); - } - - @override - bool visitFutureOrType(FutureOrType node) { - return visit(node.typeArgument); - } - - @override - bool visitTypedefType(TypedefType node) { - return node.typeArguments.any(visit); - } - @override bool visitFunctionType(FunctionType node) { variables.addAll(node.typeParameters); - bool result = node.typeParameters.any(handleTypeParameter) || - node.positionalParameters.any(visit) || - node.namedParameters.any(visitNamedType) || - visit(node.returnType); + bool result = super.visitFunctionType(node); variables.removeAll(node.typeParameters); return result; } - @override - bool visitRecordType(RecordType node) { - return node.positional.any(visit) || node.named.any(visitNamedType); - } - @override bool visitTypeParameterType(TypeParameterType node) { return node.parameter.declaration == null && !variables.contains(node.parameter); } - - @override - bool visitIntersectionType(IntersectionType node) { - return visit(node.left) || visit(node.right); - } - - bool handleTypeParameter(TypeParameter node) { - assert(variables.contains(node)); - if (node.bound.accept(this)) return true; - return node.defaultType.accept(this); - } } -class _FreeTypeVariableVisitor implements DartTypeVisitor { +class _FreeTypeVariableVisitor extends FindTypeVisitor { final Set boundVariables; _FreeTypeVariableVisitor({Set? boundVariables}) : this.boundVariables = boundVariables ?? {}; - bool visit(DartType node) => node.accept(this); - - @override - bool defaultDartType(DartType node) { - throw new UnsupportedError("Unsupported type $node (${node.runtimeType}."); - } - - bool visitNamedType(NamedType node) { - return visit(node.type); - } - - @override - bool visitNeverType(NeverType node) => false; - @override - bool visitNullType(NullType node) => false; - @override - bool visitInvalidType(InvalidType node) => false; - @override - bool visitDynamicType(DynamicType node) => false; - @override - bool visitVoidType(VoidType node) => false; - - @override - bool visitInterfaceType(InterfaceType node) { - return node.typeArguments.any(visit); - } - - @override - bool visitExtensionType(ExtensionType node) { - return node.typeArguments.any(visit); - } - - @override - bool visitFutureOrType(FutureOrType node) { - return visit(node.typeArgument); - } - - @override - bool visitTypedefType(TypedefType node) { - return node.typeArguments.any(visit); - } + bool visit(DartType type) => type.accept(this); @override bool visitFunctionType(FunctionType node) { boundVariables.addAll(node.typeParameters); - bool result = node.typeParameters.any(handleTypeParameter) || - node.positionalParameters.any(visit) || - node.namedParameters.any(visitNamedType) || - visit(node.returnType); + bool result = super.visitFunctionType(node); boundVariables.removeAll(node.typeParameters); return result; } - @override - bool visitRecordType(RecordType node) { - return node.positional.any(visit) || node.named.any(visitNamedType); - } - @override bool visitTypeParameterType(TypeParameterType node) { return !boundVariables.contains(node.parameter); } - - @override - bool visitIntersectionType(IntersectionType node) { - return visit(node.left) && visit(node.right); - } - - bool handleTypeParameter(TypeParameter node) { - assert(boundVariables.contains(node)); - if (node.bound.accept(this)) return true; - return node.defaultType.accept(this); - } } Nullability uniteNullabilities(Nullability a, Nullability b) { diff --git a/pkg/kernel/lib/visitor.dart b/pkg/kernel/lib/visitor.dart index 6a3deb1a9d9..3e28ea78525 100644 --- a/pkg/kernel/lib/visitor.dart +++ b/pkg/kernel/lib/visitor.dart @@ -901,42 +901,108 @@ abstract class TreeVisitor1 abstract class DartTypeVisitor { const DartTypeVisitor(); + // TODO(johnniwinther): Remove this. R defaultDartType(DartType node); + R visitInvalidType(InvalidType node); + R visitDynamicType(DynamicType node); + R visitVoidType(VoidType node); + R visitInterfaceType(InterfaceType node); + R visitFutureOrType(FutureOrType node); + R visitFunctionType(FunctionType node); + R visitTypeParameterType(TypeParameterType node); + R visitTypedefType(TypedefType node); + R visitNeverType(NeverType node); + R visitNullType(NullType node); + R visitExtensionType(ExtensionType node); + R visitIntersectionType(IntersectionType node); + R visitRecordType(RecordType node); +} + +mixin DartTypeVisitorDefaultMixin implements DartTypeVisitor { + @override + R defaultDartType(DartType node); + + @override R visitInvalidType(InvalidType node) => defaultDartType(node); + @override R visitDynamicType(DynamicType node) => defaultDartType(node); + @override R visitVoidType(VoidType node) => defaultDartType(node); + @override R visitInterfaceType(InterfaceType node) => defaultDartType(node); + @override R visitFutureOrType(FutureOrType node) => defaultDartType(node); + @override R visitFunctionType(FunctionType node) => defaultDartType(node); + @override R visitTypeParameterType(TypeParameterType node) => defaultDartType(node); + @override R visitTypedefType(TypedefType node) => defaultDartType(node); + @override R visitNeverType(NeverType node) => defaultDartType(node); + @override R visitNullType(NullType node) => defaultDartType(node); + @override R visitExtensionType(ExtensionType node) => defaultDartType(node); + @override R visitIntersectionType(IntersectionType node) => defaultDartType(node); + @override R visitRecordType(RecordType node) => defaultDartType(node); } abstract class DartTypeVisitor1 { const DartTypeVisitor1(); + // TODO(johnniwinther): Remove this. R defaultDartType(DartType node, A arg); + R visitInvalidType(InvalidType node, A arg); + R visitDynamicType(DynamicType node, A arg); + R visitVoidType(VoidType node, A arg); + R visitInterfaceType(InterfaceType node, A arg); + R visitFutureOrType(FutureOrType node, A arg); + R visitFunctionType(FunctionType node, A arg); + R visitTypeParameterType(TypeParameterType node, A arg); + R visitTypedefType(TypedefType node, A arg); + R visitNeverType(NeverType node, A arg); + R visitNullType(NullType node, A arg); + R visitExtensionType(ExtensionType node, A arg); + R visitIntersectionType(IntersectionType node, A arg); + R visitRecordType(RecordType node, A arg); +} + +mixin DartTypeVisitor1DefaultMixin implements DartTypeVisitor1 { + @override + R defaultDartType(DartType node, A arg); + + @override R visitInvalidType(InvalidType node, A arg) => defaultDartType(node, arg); + @override R visitDynamicType(DynamicType node, A arg) => defaultDartType(node, arg); + @override R visitVoidType(VoidType node, A arg) => defaultDartType(node, arg); + @override R visitInterfaceType(InterfaceType node, A arg) => defaultDartType(node, arg); + @override R visitFutureOrType(FutureOrType node, A arg) => defaultDartType(node, arg); + @override R visitFunctionType(FunctionType node, A arg) => defaultDartType(node, arg); + @override R visitTypeParameterType(TypeParameterType node, A arg) => defaultDartType(node, arg); + @override R visitTypedefType(TypedefType node, A arg) => defaultDartType(node, arg); + @override R visitNeverType(NeverType node, A arg) => defaultDartType(node, arg); + @override R visitNullType(NullType node, A arg) => defaultDartType(node, arg); + @override R visitExtensionType(ExtensionType node, A arg) => defaultDartType(node, arg); + @override R visitIntersectionType(IntersectionType node, A arg) => defaultDartType(node, arg); + @override R visitRecordType(RecordType node, A arg) => defaultDartType(node, arg); } diff --git a/pkg/vm/lib/transformations/type_flow/summary_collector.dart b/pkg/vm/lib/transformations/type_flow/summary_collector.dart index a80592f77dd..4279a9aeb9d 100644 --- a/pkg/vm/lib/transformations/type_flow/summary_collector.dart +++ b/pkg/vm/lib/transformations/type_flow/summary_collector.dart @@ -2505,6 +2505,7 @@ class SummaryCollector extends RecursiveResultVisitor { } class RuntimeTypeTranslatorImpl extends DartTypeVisitor + with DartTypeVisitorDefaultMixin implements RuntimeTypeTranslator { final CoreTypes coreTypes; final Summary? summary;