diff --git a/pkg/front_end/lib/src/kernel/body_builder.dart b/pkg/front_end/lib/src/kernel/body_builder.dart index d3e9e9828f4..58d482b9e44 100644 --- a/pkg/front_end/lib/src/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/kernel/body_builder.dart @@ -9323,6 +9323,9 @@ class BodyBuilder extends StackListenerImpl pop() as List?; // typeArguments if (libraryFeatures.constructorTearoffs.isEnabled) { Object? operand = pop(); + if (operand is DotShorthandPropertyGet && typeArguments != null) { + operand.hasTypeParameters = true; + } if (operand is Generator) { push(operand.applyTypeArguments( openAngleBracket.charOffset, typeArguments)); diff --git a/pkg/front_end/lib/src/kernel/internal_ast.dart b/pkg/front_end/lib/src/kernel/internal_ast.dart index 9b01bb526e0..5120f853284 100644 --- a/pkg/front_end/lib/src/kernel/internal_ast.dart +++ b/pkg/front_end/lib/src/kernel/internal_ast.dart @@ -3293,7 +3293,14 @@ class DotShorthandPropertyGet extends InternalExpression { final Name name; final int nameOffset; - DotShorthandPropertyGet(this.name, {required this.nameOffset}); + /// Whether this dot shorthand has type parameters. + /// + /// Used for error checking for constructors with type parameters in the + /// [InferenceVisitor]. + bool hasTypeParameters; + + DotShorthandPropertyGet(this.name, + {required this.nameOffset, this.hasTypeParameters = false}); @override ExpressionInferenceResult acceptInference( diff --git a/pkg/front_end/lib/src/type_inference/inference_visitor.dart b/pkg/front_end/lib/src/type_inference/inference_visitor.dart index fb322ff02c1..f6fbe246d19 100644 --- a/pkg/front_end/lib/src/type_inference/inference_visitor.dart +++ b/pkg/front_end/lib/src/type_inference/inference_visitor.dart @@ -697,6 +697,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase ExpressionInferenceResult operandResult = inferExpression( node.expression, const UnknownType(), isVoidAllowed: true); + if (operandResult.expression is InvalidExpression) return operandResult; Expression operand = operandResult.expression; DartType operandType = operandResult.inferredType; if (operandType is! FunctionType) { @@ -12289,12 +12290,42 @@ class InferenceVisitorImpl extends InferenceVisitorBase expressionInferenceResult = inferExpression(new StaticGet(member), cachedContext); } else { - // Tearoff like `Object.new`; - expressionInferenceResult = - inferExpression(new StaticTearOff(member), cachedContext); + // Method tearoffs. + DartType type = + member.function.computeFunctionType(Nullability.nonNullable); + return instantiateTearOff( + type, typeContext, new StaticTearOff(member)); } case Constructor(): case null: + // Handle constructor tearoffs. + if (cachedContext is TypeDeclarationType) { + Member? constructor = findConstructor( + cachedContext, node.name, node.fileOffset, + isTearoff: true); + // Dot shorthand constructor invocations with type parameters + // `.id()` are not allowed. + if (constructor != null && node.hasTypeParameters) { + return new ExpressionInferenceResult( + const DynamicType(), + helper.buildProblem( + messageDotShorthandsConstructorInvocationWithTypeArguments, + node.nameOffset, + node.name.text.length)); + } + if (constructor is Constructor) { + DartType type = constructor.function + .computeFunctionType(Nullability.nonNullable); + return instantiateTearOff( + type, typeContext, new ConstructorTearOff(constructor)); + } else if (constructor is Procedure) { + DartType type = constructor.function + .computeFunctionType(Nullability.nonNullable); + return instantiateTearOff( + type, typeContext, new StaticTearOff(constructor)); + } + } + if (isKnown(cachedContext)) { // Error when we can't find the static getter or field [node.name] in // the declaration of [cachedContext]. diff --git a/pkg/front_end/lib/src/type_inference/inference_visitor_base.dart b/pkg/front_end/lib/src/type_inference/inference_visitor_base.dart index 057bb4cb4e6..8adfc91da2b 100644 --- a/pkg/front_end/lib/src/type_inference/inference_visitor_base.dart +++ b/pkg/front_end/lib/src/type_inference/inference_visitor_base.dart @@ -1148,7 +1148,8 @@ abstract class InferenceVisitorBase implements InferenceVisitor { } /// Finds a constructor of [type] called [name]. - Member? findConstructor(TypeDeclarationType type, Name name, int fileOffset) { + Member? findConstructor(TypeDeclarationType type, Name name, int fileOffset, + {bool isTearoff = false}) { // TODO(Dart Model team): Seems like an abstraction level issue to require // going from `Class` objects back to builders to find a `Member`. DeclarationBuilder builder; @@ -1164,7 +1165,9 @@ abstract class InferenceVisitorBase implements InferenceVisitor { MemberBuilder? constructorBuilder = builder.findConstructorOrFactory( name.text, fileOffset, helper.uri, libraryBuilder); - return constructorBuilder?.invokeTarget; + return isTearoff + ? constructorBuilder?.readTarget + : constructorBuilder?.invokeTarget; } /// Finds a member of [receiverType] called [name], and if it is found, diff --git a/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.expect b/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.expect index c823041db5c..fb625a86421 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.expect @@ -179,11 +179,6 @@ library; // Class.named; // ^^^^^ // -// pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// Class.named; -// ^ -// // pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:22:8: Error: The operator '<' isn't defined for the class 'Type'. // - 'Type' is from 'dart:core'. // Try correcting the operator to an existing operator, or defining a '<' operator. @@ -276,10 +271,11 @@ Try correcting the name to the name of an existing method, or defining a method - 'Type' is from 'dart:core'. Try correcting the operator to an existing operator, or defining a '<' operator. Class.named; - ^" in #C2{}.<(#C3){dynamic}.>(invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + ^" in #C2{}.<(#C3){dynamic}.>(invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:19: Error: The getter 'named' isn't defined for the class 'List'. + - 'List' is from 'dart:core'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'. Class.named; - ^"); + ^^^^^" in []{}.named); invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:22:8: Error: The operator '<' isn't defined for the class 'Type'. - 'Type' is from 'dart:core'. Try correcting the operator to an existing operator, or defining a '<' operator. diff --git a/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.modular.expect b/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.modular.expect index c823041db5c..fb625a86421 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.modular.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.modular.expect @@ -179,11 +179,6 @@ library; // Class.named; // ^^^^^ // -// pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// Class.named; -// ^ -// // pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:22:8: Error: The operator '<' isn't defined for the class 'Type'. // - 'Type' is from 'dart:core'. // Try correcting the operator to an existing operator, or defining a '<' operator. @@ -276,10 +271,11 @@ Try correcting the name to the name of an existing method, or defining a method - 'Type' is from 'dart:core'. Try correcting the operator to an existing operator, or defining a '<' operator. Class.named; - ^" in #C2{}.<(#C3){dynamic}.>(invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + ^" in #C2{}.<(#C3){dynamic}.>(invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:19: Error: The getter 'named' isn't defined for the class 'List'. + - 'List' is from 'dart:core'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'. Class.named; - ^"); + ^^^^^" in []{}.named); invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:22:8: Error: The operator '<' isn't defined for the class 'Type'. - 'Type' is from 'dart:core'. Try correcting the operator to an existing operator, or defining a '<' operator. diff --git a/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.transformed.expect b/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.transformed.expect index df563c069f6..0054772403b 100644 --- a/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart.strong.transformed.expect @@ -179,11 +179,6 @@ library; // Class.named; // ^^^^^ // -// pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// Class.named; -// ^ -// // pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:22:8: Error: The operator '<' isn't defined for the class 'Type'. // - 'Type' is from 'dart:core'. // Try correcting the operator to an existing operator, or defining a '<' operator. @@ -276,10 +271,11 @@ Try correcting the name to the name of an existing method, or defining a method - 'Type' is from 'dart:core'. Try correcting the operator to an existing operator, or defining a '<' operator. Class.named; - ^" in #C2{}.<(#C3){dynamic}.>(invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + ^" in #C2{}.<(#C3){dynamic}.>(invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:21:19: Error: The getter 'named' isn't defined for the class 'List'. + - 'List' is from 'dart:core'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'named'. Class.named; - ^"); + ^^^^^" in core::_GrowableList::•(0){}.named); invalid-expression "pkg/front_end/testcases/constructor_tearoffs/duplicate_instantiation.dart:22:8: Error: The operator '<' isn't defined for the class 'Type'. - 'Type' is from 'dart:core'. Try correcting the operator to an existing operator, or defining a '<' operator. diff --git a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart index 01da07cba7c..6cf739699d6 100644 --- a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart +++ b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart @@ -7,8 +7,12 @@ class C { C.named(); } +extension type ET(T v) {} + void test() { C newConstructor = .new(); C namedConstructor = .named(); C newTearoff = .new; + C namedTearoff = .new; + ET e = .new; } diff --git a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.expect b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.expect index c212a05ae47..680e769bc26 100644 --- a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.expect +++ b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.expect @@ -2,26 +2,30 @@ library; // // Problems in library: // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:11:23: Error: A dot shorthand constructor invocation can't have type arguments. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:23: Error: A dot shorthand constructor invocation can't have type arguments. // Try adding the class name and type arguments explicitly before the constructor name. // C newConstructor = .new(); // ^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:12:25: Error: A dot shorthand constructor invocation can't have type arguments. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:14:25: Error: A dot shorthand constructor invocation can't have type arguments. // Try adding the class name and type arguments explicitly before the constructor name. // C namedConstructor = .named(); // ^^^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:19: Error: The static getter or field 'new' isn't defined for the type 'C'. -// - 'C' is from 'pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart'. -// Try correcting the name to the name of an existing static getter or field, or defining a getter or field named 'new'. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:15:19: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. // C newTearoff = .new; // ^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:22: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// C newTearoff = .new; -// ^ +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:16:21: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. +// C namedTearoff = .new; +// ^^^ +// +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:17:11: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. +// ET e = .new; +// ^^^ // import self as self; import "dart:core" as core; @@ -34,17 +38,36 @@ class C extends core::Object { : super core::Object::•() ; } +extension type ET(T% v) { + abstract extension-type-member representation-field get v() → T%; + constructor • = self::ET|constructor#; + constructor tearoff • = self::ET|constructor#_#new#tearOff; +} +static extension-type-member method ET|constructor#(self::ET|constructor#::T% v) → self::ET% /* erasure=self::ET|constructor#::T%, declared=! */ { + lowered final self::ET% /* erasure=self::ET|constructor#::T%, declared=! */ #this = v; + return #this; +} +static extension-type-member method ET|constructor#_#new#tearOff(self::ET|constructor#_#new#tearOff::T% v) → self::ET% /* erasure=self::ET|constructor#_#new#tearOff::T%, declared=! */ + return self::ET|constructor#(v); static method test() → void { - self::C newConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:11:23: Error: A dot shorthand constructor invocation can't have type arguments. + self::C newConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:23: Error: A dot shorthand constructor invocation can't have type arguments. Try adding the class name and type arguments explicitly before the constructor name. C newConstructor = .new(); ^^^" as{TypeError,ForDynamic} self::C; - self::C namedConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:12:25: Error: A dot shorthand constructor invocation can't have type arguments. + self::C namedConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:14:25: Error: A dot shorthand constructor invocation can't have type arguments. Try adding the class name and type arguments explicitly before the constructor name. C namedConstructor = .named(); ^^^^^" as{TypeError,ForDynamic} self::C; - self::C newTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:22: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + self::C newTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:15:19: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. C newTearoff = .new; - ^"; + ^^^" as{TypeError,ForDynamic} self::C; + self::C namedTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:16:21: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. + C namedTearoff = .new; + ^^^" as{TypeError,ForDynamic} self::C; + self::ET% /* erasure=dynamic, declared=! */ e = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:17:11: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. + ET e = .new; + ^^^" as{TypeError,ForDynamic} self::ET% /* erasure=dynamic, declared=! */; } diff --git a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.modular.expect b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.modular.expect index c212a05ae47..680e769bc26 100644 --- a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.modular.expect +++ b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.modular.expect @@ -2,26 +2,30 @@ library; // // Problems in library: // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:11:23: Error: A dot shorthand constructor invocation can't have type arguments. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:23: Error: A dot shorthand constructor invocation can't have type arguments. // Try adding the class name and type arguments explicitly before the constructor name. // C newConstructor = .new(); // ^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:12:25: Error: A dot shorthand constructor invocation can't have type arguments. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:14:25: Error: A dot shorthand constructor invocation can't have type arguments. // Try adding the class name and type arguments explicitly before the constructor name. // C namedConstructor = .named(); // ^^^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:19: Error: The static getter or field 'new' isn't defined for the type 'C'. -// - 'C' is from 'pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart'. -// Try correcting the name to the name of an existing static getter or field, or defining a getter or field named 'new'. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:15:19: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. // C newTearoff = .new; // ^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:22: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// C newTearoff = .new; -// ^ +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:16:21: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. +// C namedTearoff = .new; +// ^^^ +// +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:17:11: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. +// ET e = .new; +// ^^^ // import self as self; import "dart:core" as core; @@ -34,17 +38,36 @@ class C extends core::Object { : super core::Object::•() ; } +extension type ET(T% v) { + abstract extension-type-member representation-field get v() → T%; + constructor • = self::ET|constructor#; + constructor tearoff • = self::ET|constructor#_#new#tearOff; +} +static extension-type-member method ET|constructor#(self::ET|constructor#::T% v) → self::ET% /* erasure=self::ET|constructor#::T%, declared=! */ { + lowered final self::ET% /* erasure=self::ET|constructor#::T%, declared=! */ #this = v; + return #this; +} +static extension-type-member method ET|constructor#_#new#tearOff(self::ET|constructor#_#new#tearOff::T% v) → self::ET% /* erasure=self::ET|constructor#_#new#tearOff::T%, declared=! */ + return self::ET|constructor#(v); static method test() → void { - self::C newConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:11:23: Error: A dot shorthand constructor invocation can't have type arguments. + self::C newConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:23: Error: A dot shorthand constructor invocation can't have type arguments. Try adding the class name and type arguments explicitly before the constructor name. C newConstructor = .new(); ^^^" as{TypeError,ForDynamic} self::C; - self::C namedConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:12:25: Error: A dot shorthand constructor invocation can't have type arguments. + self::C namedConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:14:25: Error: A dot shorthand constructor invocation can't have type arguments. Try adding the class name and type arguments explicitly before the constructor name. C namedConstructor = .named(); ^^^^^" as{TypeError,ForDynamic} self::C; - self::C newTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:22: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + self::C newTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:15:19: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. C newTearoff = .new; - ^"; + ^^^" as{TypeError,ForDynamic} self::C; + self::C namedTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:16:21: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. + C namedTearoff = .new; + ^^^" as{TypeError,ForDynamic} self::C; + self::ET% /* erasure=dynamic, declared=! */ e = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:17:11: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. + ET e = .new; + ^^^" as{TypeError,ForDynamic} self::ET% /* erasure=dynamic, declared=! */; } diff --git a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.outline.expect b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.outline.expect index 4a7a5d90e13..e16db4efc0c 100644 --- a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.outline.expect +++ b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.outline.expect @@ -8,5 +8,14 @@ class C extends core::Object { constructor named() → self::C ; } +extension type ET(T% v) { + abstract extension-type-member representation-field get v() → T%; + constructor • = self::ET|constructor#; + constructor tearoff • = self::ET|constructor#_#new#tearOff; +} +static extension-type-member method ET|constructor#(self::ET|constructor#::T% v) → self::ET% /* erasure=self::ET|constructor#::T%, declared=! */ + ; +static extension-type-member method ET|constructor#_#new#tearOff(self::ET|constructor#_#new#tearOff::T% v) → self::ET% /* erasure=self::ET|constructor#_#new#tearOff::T%, declared=! */ + return self::ET|constructor#(v); static method test() → void ; diff --git a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.transformed.expect b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.transformed.expect index ecfdfc3723d..e6f39f2d486 100644 --- a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.strong.transformed.expect @@ -2,26 +2,30 @@ library; // // Problems in library: // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:11:23: Error: A dot shorthand constructor invocation can't have type arguments. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:23: Error: A dot shorthand constructor invocation can't have type arguments. // Try adding the class name and type arguments explicitly before the constructor name. // C newConstructor = .new(); // ^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:12:25: Error: A dot shorthand constructor invocation can't have type arguments. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:14:25: Error: A dot shorthand constructor invocation can't have type arguments. // Try adding the class name and type arguments explicitly before the constructor name. // C namedConstructor = .named(); // ^^^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:19: Error: The static getter or field 'new' isn't defined for the type 'C'. -// - 'C' is from 'pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart'. -// Try correcting the name to the name of an existing static getter or field, or defining a getter or field named 'new'. +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:15:19: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. // C newTearoff = .new; // ^^^ // -// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:22: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// C newTearoff = .new; -// ^ +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:16:21: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. +// C namedTearoff = .new; +// ^^^ +// +// pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:17:11: Error: A dot shorthand constructor invocation can't have type arguments. +// Try adding the class name and type arguments explicitly before the constructor name. +// ET e = .new; +// ^^^ // import self as self; import "dart:core" as core; @@ -34,17 +38,36 @@ class C extends core::Object { : super core::Object::•() ; } +extension type ET(T% v) { + abstract extension-type-member representation-field get v() → T%; + constructor • = self::ET|constructor#; + constructor tearoff • = self::ET|constructor#_#new#tearOff; +} +static extension-type-member method ET|constructor#(self::ET|constructor#::T% v) → self::ET% /* erasure=self::ET|constructor#::T%, declared=! */ { + lowered final self::ET% /* erasure=self::ET|constructor#::T%, declared=! */ #this = v; + return #this; +} +static extension-type-member method ET|constructor#_#new#tearOff(self::ET|constructor#_#new#tearOff::T% v) → self::ET% /* erasure=self::ET|constructor#_#new#tearOff::T%, declared=! */ + return self::ET|constructor#(v); static method test() → void { - self::C newConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:11:23: Error: A dot shorthand constructor invocation can't have type arguments. + self::C newConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:23: Error: A dot shorthand constructor invocation can't have type arguments. Try adding the class name and type arguments explicitly before the constructor name. C newConstructor = .new(); ^^^" as{TypeError,ForDynamic,Unchecked} self::C; - self::C namedConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:12:25: Error: A dot shorthand constructor invocation can't have type arguments. + self::C namedConstructor = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:14:25: Error: A dot shorthand constructor invocation can't have type arguments. Try adding the class name and type arguments explicitly before the constructor name. C namedConstructor = .named(); ^^^^^" as{TypeError,ForDynamic,Unchecked} self::C; - self::C newTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:13:22: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + self::C newTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:15:19: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. C newTearoff = .new; - ^"; + ^^^" as{TypeError,ForDynamic,Unchecked} self::C; + self::C namedTearoff = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:16:21: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. + C namedTearoff = .new; + ^^^" as{TypeError,ForDynamic,Unchecked} self::C; + self::ET% /* erasure=dynamic, declared=! */ e = invalid-expression "pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart:17:11: Error: A dot shorthand constructor invocation can't have type arguments. +Try adding the class name and type arguments explicitly before the constructor name. + ET e = .new; + ^^^" as{TypeError,ForDynamic,Unchecked} self::ET% /* erasure=dynamic, declared=! */; } diff --git a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline.expect b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline.expect index 326f64d5d13..4afdb89648e 100644 --- a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline.expect +++ b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline.expect @@ -3,4 +3,6 @@ class C { C.named(); } +extension type ET(T v) {} + void test() {} diff --git a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline_modelled.expect index 326f64d5d13..4afdb89648e 100644 --- a/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/dot_shorthands/constructor_type_parameter_error.dart.textual_outline_modelled.expect @@ -3,4 +3,6 @@ class C { C.named(); } +extension type ET(T v) {} + void test() {} diff --git a/pkg/front_end/testcases/dot_shorthands/tearoff.dart b/pkg/front_end/testcases/dot_shorthands/tearoff.dart index e9986ca7084..11df3accb35 100644 --- a/pkg/front_end/testcases/dot_shorthands/tearoff.dart +++ b/pkg/front_end/testcases/dot_shorthands/tearoff.dart @@ -2,6 +2,29 @@ // 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. +class C { + static C d() => C(); + C(); +} + +class C1 { + @override + bool operator ==(Object other) => identical(C1.new, other); +} + +class A1 { + bool operator ==(Object other) => identical(ET1.new, other); +} + +extension type ET1(A1 _) implements A1 {} + void main() { Object o = .hash; + print(C1() == .new); + print(ET1(A1()) == .new); + + Object? c = C(); + if (c is C) { + c = .d; + } } diff --git a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.expect b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.expect index be66ea0c940..9fdb48f58d8 100644 --- a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.expect +++ b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.expect @@ -2,10 +2,54 @@ library; import self as self; import "dart:core" as core; +class C extends core::Object { + constructor •() → self::C + : super core::Object::•() + ; + static method d() → self::C + return new self::C::•(); +} +class C1 extends core::Object { + synthetic constructor •() → self::C1 + : super core::Object::•() + ; + @#C1 + operator ==(core::Object other) → core::bool + return core::identical(#C2, other); +} +class A1 extends core::Object { + synthetic constructor •() → self::A1 + : super core::Object::•() + ; + operator ==(core::Object other) → core::bool + return core::identical(#C3, other); +} +extension type ET1(self::A1 _) implements self::A1 { + abstract extension-type-member representation-field get _() → self::A1; + constructor • = self::ET1|constructor#; + constructor tearoff • = self::ET1|constructor#_#new#tearOff; +} +static extension-type-member method ET1|constructor#(self::A1 _) → self::ET1 /* erasure=self::A1 */ { + lowered final self::ET1 /* erasure=self::A1 */ #this = _; + return #this; +} +static extension-type-member method ET1|constructor#_#new#tearOff(self::A1 _) → self::ET1 /* erasure=self::A1 */ + return self::ET1|constructor#(_); static method main() → void { - core::Object o = #C1; + core::Object o = #C4; + core::print(new self::C1::•() =={self::C1::==}{(core::Object) → core::bool} #C2); + core::print(self::ET1|constructor#(new self::A1::•()) =={self::A1::==}{(core::Object) → core::bool} #C3); + core::Object? c = new self::C::•(); + if(c{core::Object} is self::C) { + c = #C6; + } } constants { - #C1 = static-tearoff core::Object::hash + #C1 = core::_Override {} + #C2 = constructor-tearoff self::C1::• + #C3 = static-tearoff self::ET1|constructor#_#new#tearOff + #C4 = static-tearoff core::Object::hash + #C5 = static-tearoff self::C::d + #C6 = instantiation #C5 } diff --git a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.modular.expect b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.modular.expect index be66ea0c940..9fdb48f58d8 100644 --- a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.modular.expect +++ b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.modular.expect @@ -2,10 +2,54 @@ library; import self as self; import "dart:core" as core; +class C extends core::Object { + constructor •() → self::C + : super core::Object::•() + ; + static method d() → self::C + return new self::C::•(); +} +class C1 extends core::Object { + synthetic constructor •() → self::C1 + : super core::Object::•() + ; + @#C1 + operator ==(core::Object other) → core::bool + return core::identical(#C2, other); +} +class A1 extends core::Object { + synthetic constructor •() → self::A1 + : super core::Object::•() + ; + operator ==(core::Object other) → core::bool + return core::identical(#C3, other); +} +extension type ET1(self::A1 _) implements self::A1 { + abstract extension-type-member representation-field get _() → self::A1; + constructor • = self::ET1|constructor#; + constructor tearoff • = self::ET1|constructor#_#new#tearOff; +} +static extension-type-member method ET1|constructor#(self::A1 _) → self::ET1 /* erasure=self::A1 */ { + lowered final self::ET1 /* erasure=self::A1 */ #this = _; + return #this; +} +static extension-type-member method ET1|constructor#_#new#tearOff(self::A1 _) → self::ET1 /* erasure=self::A1 */ + return self::ET1|constructor#(_); static method main() → void { - core::Object o = #C1; + core::Object o = #C4; + core::print(new self::C1::•() =={self::C1::==}{(core::Object) → core::bool} #C2); + core::print(self::ET1|constructor#(new self::A1::•()) =={self::A1::==}{(core::Object) → core::bool} #C3); + core::Object? c = new self::C::•(); + if(c{core::Object} is self::C) { + c = #C6; + } } constants { - #C1 = static-tearoff core::Object::hash + #C1 = core::_Override {} + #C2 = constructor-tearoff self::C1::• + #C3 = static-tearoff self::ET1|constructor#_#new#tearOff + #C4 = static-tearoff core::Object::hash + #C5 = static-tearoff self::C::d + #C6 = instantiation #C5 } diff --git a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.outline.expect b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.outline.expect index 2982c48b884..396e05b1c22 100644 --- a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.outline.expect +++ b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.outline.expect @@ -1,5 +1,39 @@ library; import self as self; +import "dart:core" as core; +class C extends core::Object { + constructor •() → self::C + ; + static method d() → self::C + ; +} +class C1 extends core::Object { + synthetic constructor •() → self::C1 + ; + @core::override + operator ==(core::Object other) → core::bool + ; +} +class A1 extends core::Object { + synthetic constructor •() → self::A1 + ; + operator ==(core::Object other) → core::bool + ; +} +extension type ET1(self::A1 _) implements self::A1 { + abstract extension-type-member representation-field get _() → self::A1; + constructor • = self::ET1|constructor#; + constructor tearoff • = self::ET1|constructor#_#new#tearOff; +} +static extension-type-member method ET1|constructor#(self::A1 _) → self::ET1 /* erasure=self::A1 */ + ; +static extension-type-member method ET1|constructor#_#new#tearOff(self::A1 _) → self::ET1 /* erasure=self::A1 */ + return self::ET1|constructor#(_); static method main() → void ; + + +Extra constant evaluation status: +Evaluated: StaticGet @ org-dartlang-testcase:///tearoff.dart:11:4 -> InstanceConstant(const _Override{}) +Extra constant evaluation: evaluated: 3, effectively constant: 1 diff --git a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.transformed.expect b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.transformed.expect index be66ea0c940..9fdb48f58d8 100644 --- a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.strong.transformed.expect @@ -2,10 +2,54 @@ library; import self as self; import "dart:core" as core; +class C extends core::Object { + constructor •() → self::C + : super core::Object::•() + ; + static method d() → self::C + return new self::C::•(); +} +class C1 extends core::Object { + synthetic constructor •() → self::C1 + : super core::Object::•() + ; + @#C1 + operator ==(core::Object other) → core::bool + return core::identical(#C2, other); +} +class A1 extends core::Object { + synthetic constructor •() → self::A1 + : super core::Object::•() + ; + operator ==(core::Object other) → core::bool + return core::identical(#C3, other); +} +extension type ET1(self::A1 _) implements self::A1 { + abstract extension-type-member representation-field get _() → self::A1; + constructor • = self::ET1|constructor#; + constructor tearoff • = self::ET1|constructor#_#new#tearOff; +} +static extension-type-member method ET1|constructor#(self::A1 _) → self::ET1 /* erasure=self::A1 */ { + lowered final self::ET1 /* erasure=self::A1 */ #this = _; + return #this; +} +static extension-type-member method ET1|constructor#_#new#tearOff(self::A1 _) → self::ET1 /* erasure=self::A1 */ + return self::ET1|constructor#(_); static method main() → void { - core::Object o = #C1; + core::Object o = #C4; + core::print(new self::C1::•() =={self::C1::==}{(core::Object) → core::bool} #C2); + core::print(self::ET1|constructor#(new self::A1::•()) =={self::A1::==}{(core::Object) → core::bool} #C3); + core::Object? c = new self::C::•(); + if(c{core::Object} is self::C) { + c = #C6; + } } constants { - #C1 = static-tearoff core::Object::hash + #C1 = core::_Override {} + #C2 = constructor-tearoff self::C1::• + #C3 = static-tearoff self::ET1|constructor#_#new#tearOff + #C4 = static-tearoff core::Object::hash + #C5 = static-tearoff self::C::d + #C6 = instantiation #C5 } diff --git a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline.expect b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline.expect index ab73b3a234a..10ed649f6a7 100644 --- a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline.expect +++ b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline.expect @@ -1 +1,17 @@ +class C { + static C d() => C(); + C(); +} + +class C1 { + @override + bool operator ==(Object other) => identical(C1.new, other); +} + +class A1 { + bool operator ==(Object other) => identical(ET1.new, other); +} + +extension type ET1(A1 _) implements A1 {} + void main() {} diff --git a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline_modelled.expect index ab73b3a234a..5d6dd4b15e1 100644 --- a/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/dot_shorthands/tearoff.dart.textual_outline_modelled.expect @@ -1 +1,17 @@ +class A1 { + bool operator ==(Object other) => identical(ET1.new, other); +} + +class C { + C(); + static C d() => C(); +} + +class C1 { + @override + bool operator ==(Object other) => identical(C1.new, other); +} + +extension type ET1(A1 _) implements A1 {} + void main() {} diff --git a/pkg/front_end/testcases/extension_types/field_access.dart.strong.expect b/pkg/front_end/testcases/extension_types/field_access.dart.strong.expect index e8731dc3f19..808ceb243f5 100644 --- a/pkg/front_end/testcases/extension_types/field_access.dart.strong.expect +++ b/pkg/front_end/testcases/extension_types/field_access.dart.strong.expect @@ -261,11 +261,6 @@ library; // var h2 = privateInlineClass._it; // Error // ^^^ // -// pkg/front_end/testcases/extension_types/field_access.dart:158:34: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// var h2 = privateInlineClass._it; // Error -// ^ -// // pkg/front_end/testcases/extension_types/field_access.dart:159:31: Error: The setter '_it' isn't defined for the class 'PrivateInlineClass'. // Try correcting the name to the name of an existing setter, or defining a setter or field named '_it'. // var h3 = privateInlineClass._it = 42; // Error @@ -628,10 +623,10 @@ Try correcting the name to the name of an existing setter, or defining a setter Try correcting the name to the name of an existing getter, or defining a getter or field named '_it'. var h1 = privateInlineClass._it; // Error ^^^" in privateInlineClass{}._it; - invalid-type h2 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:158:34: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + dynamic h2 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:158:31: Error: The getter '_it' isn't defined for the class 'PrivateInlineClass'. +Try correcting the name to the name of an existing getter, or defining a getter or field named '_it'. var h2 = privateInlineClass._it; // Error - ^"; + ^^^" in privateInlineClass{}._it; core::int h3 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:159:31: Error: The setter '_it' isn't defined for the class 'PrivateInlineClass'. Try correcting the name to the name of an existing setter, or defining a setter or field named '_it'. var h3 = privateInlineClass._it = 42; // Error diff --git a/pkg/front_end/testcases/extension_types/field_access.dart.strong.modular.expect b/pkg/front_end/testcases/extension_types/field_access.dart.strong.modular.expect index e8731dc3f19..808ceb243f5 100644 --- a/pkg/front_end/testcases/extension_types/field_access.dart.strong.modular.expect +++ b/pkg/front_end/testcases/extension_types/field_access.dart.strong.modular.expect @@ -261,11 +261,6 @@ library; // var h2 = privateInlineClass._it; // Error // ^^^ // -// pkg/front_end/testcases/extension_types/field_access.dart:158:34: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// var h2 = privateInlineClass._it; // Error -// ^ -// // pkg/front_end/testcases/extension_types/field_access.dart:159:31: Error: The setter '_it' isn't defined for the class 'PrivateInlineClass'. // Try correcting the name to the name of an existing setter, or defining a setter or field named '_it'. // var h3 = privateInlineClass._it = 42; // Error @@ -628,10 +623,10 @@ Try correcting the name to the name of an existing setter, or defining a setter Try correcting the name to the name of an existing getter, or defining a getter or field named '_it'. var h1 = privateInlineClass._it; // Error ^^^" in privateInlineClass{}._it; - invalid-type h2 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:158:34: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + dynamic h2 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:158:31: Error: The getter '_it' isn't defined for the class 'PrivateInlineClass'. +Try correcting the name to the name of an existing getter, or defining a getter or field named '_it'. var h2 = privateInlineClass._it; // Error - ^"; + ^^^" in privateInlineClass{}._it; core::int h3 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:159:31: Error: The setter '_it' isn't defined for the class 'PrivateInlineClass'. Try correcting the name to the name of an existing setter, or defining a setter or field named '_it'. var h3 = privateInlineClass._it = 42; // Error diff --git a/pkg/front_end/testcases/extension_types/field_access.dart.strong.transformed.expect b/pkg/front_end/testcases/extension_types/field_access.dart.strong.transformed.expect index e8731dc3f19..808ceb243f5 100644 --- a/pkg/front_end/testcases/extension_types/field_access.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/extension_types/field_access.dart.strong.transformed.expect @@ -261,11 +261,6 @@ library; // var h2 = privateInlineClass._it; // Error // ^^^ // -// pkg/front_end/testcases/extension_types/field_access.dart:158:34: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -// Try changing the operand or remove the type arguments. -// var h2 = privateInlineClass._it; // Error -// ^ -// // pkg/front_end/testcases/extension_types/field_access.dart:159:31: Error: The setter '_it' isn't defined for the class 'PrivateInlineClass'. // Try correcting the name to the name of an existing setter, or defining a setter or field named '_it'. // var h3 = privateInlineClass._it = 42; // Error @@ -628,10 +623,10 @@ Try correcting the name to the name of an existing setter, or defining a setter Try correcting the name to the name of an existing getter, or defining a getter or field named '_it'. var h1 = privateInlineClass._it; // Error ^^^" in privateInlineClass{}._it; - invalid-type h2 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:158:34: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. -Try changing the operand or remove the type arguments. + dynamic h2 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:158:31: Error: The getter '_it' isn't defined for the class 'PrivateInlineClass'. +Try correcting the name to the name of an existing getter, or defining a getter or field named '_it'. var h2 = privateInlineClass._it; // Error - ^"; + ^^^" in privateInlineClass{}._it; core::int h3 = invalid-expression "pkg/front_end/testcases/extension_types/field_access.dart:159:31: Error: The setter '_it' isn't defined for the class 'PrivateInlineClass'. Try correcting the name to the name of an existing setter, or defining a setter or field named '_it'. var h3 = privateInlineClass._it = 42; // Error diff --git a/pkg/front_end/testcases/general/missing_static_super.dart.strong.expect b/pkg/front_end/testcases/general/missing_static_super.dart.strong.expect index be896396181..f4bcf278aff 100644 --- a/pkg/front_end/testcases/general/missing_static_super.dart.strong.expect +++ b/pkg/front_end/testcases/general/missing_static_super.dart.strong.expect @@ -203,7 +203,7 @@ class Class extends self::Super { ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:15:11: Error: Superclass has no getter named 'missingSuperMethod'. super.missingSuperMethod; - ^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:16:11: Error: Superclass has no getter named 'missingSuperIndex'. super.missingSuperIndex[42]; ^^^^^^^^^^^^^^^^^"{}.[](42); @@ -232,7 +232,7 @@ class Class extends self::Super { ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:27:11: Error: Member not found: 'missingStaticMethod'. Super.missingStaticMethod; - ^^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:28:11: Error: Member not found: 'missingStaticIndex'. Super.missingStaticIndex[42]; ^^^^^^^^^^^^^^^^^^"{}.[](42); @@ -263,7 +263,7 @@ abstract class Mixin extends self::Super /*isMixinDeclaration*/ { ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:41:11: Error: Superclass has no getter named 'missingSuperMethod'. super.missingSuperMethod; - ^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:42:11: Error: Superclass has no getter named 'missingSuperIndex'. super.missingSuperIndex[42]; ^^^^^^^^^^^^^^^^^"{}.[](42); @@ -292,7 +292,7 @@ abstract class Mixin extends self::Super /*isMixinDeclaration*/ { ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:53:11: Error: Member not found: 'missingStaticMethod'. Super.missingStaticMethod; - ^^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:54:11: Error: Member not found: 'missingStaticIndex'. Super.missingStaticIndex[42]; ^^^^^^^^^^^^^^^^^^"{}.[](42); diff --git a/pkg/front_end/testcases/general/missing_static_super.dart.strong.modular.expect b/pkg/front_end/testcases/general/missing_static_super.dart.strong.modular.expect index be896396181..f4bcf278aff 100644 --- a/pkg/front_end/testcases/general/missing_static_super.dart.strong.modular.expect +++ b/pkg/front_end/testcases/general/missing_static_super.dart.strong.modular.expect @@ -203,7 +203,7 @@ class Class extends self::Super { ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:15:11: Error: Superclass has no getter named 'missingSuperMethod'. super.missingSuperMethod; - ^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:16:11: Error: Superclass has no getter named 'missingSuperIndex'. super.missingSuperIndex[42]; ^^^^^^^^^^^^^^^^^"{}.[](42); @@ -232,7 +232,7 @@ class Class extends self::Super { ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:27:11: Error: Member not found: 'missingStaticMethod'. Super.missingStaticMethod; - ^^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:28:11: Error: Member not found: 'missingStaticIndex'. Super.missingStaticIndex[42]; ^^^^^^^^^^^^^^^^^^"{}.[](42); @@ -263,7 +263,7 @@ abstract class Mixin extends self::Super /*isMixinDeclaration*/ { ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:41:11: Error: Superclass has no getter named 'missingSuperMethod'. super.missingSuperMethod; - ^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:42:11: Error: Superclass has no getter named 'missingSuperIndex'. super.missingSuperIndex[42]; ^^^^^^^^^^^^^^^^^"{}.[](42); @@ -292,7 +292,7 @@ abstract class Mixin extends self::Super /*isMixinDeclaration*/ { ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:53:11: Error: Member not found: 'missingStaticMethod'. Super.missingStaticMethod; - ^^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:54:11: Error: Member not found: 'missingStaticIndex'. Super.missingStaticIndex[42]; ^^^^^^^^^^^^^^^^^^"{}.[](42); diff --git a/pkg/front_end/testcases/general/missing_static_super.dart.strong.transformed.expect b/pkg/front_end/testcases/general/missing_static_super.dart.strong.transformed.expect index be896396181..f4bcf278aff 100644 --- a/pkg/front_end/testcases/general/missing_static_super.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/general/missing_static_super.dart.strong.transformed.expect @@ -203,7 +203,7 @@ class Class extends self::Super { ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:15:11: Error: Superclass has no getter named 'missingSuperMethod'. super.missingSuperMethod; - ^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:16:11: Error: Superclass has no getter named 'missingSuperIndex'. super.missingSuperIndex[42]; ^^^^^^^^^^^^^^^^^"{}.[](42); @@ -232,7 +232,7 @@ class Class extends self::Super { ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:27:11: Error: Member not found: 'missingStaticMethod'. Super.missingStaticMethod; - ^^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:28:11: Error: Member not found: 'missingStaticIndex'. Super.missingStaticIndex[42]; ^^^^^^^^^^^^^^^^^^"{}.[](42); @@ -263,7 +263,7 @@ abstract class Mixin extends self::Super /*isMixinDeclaration*/ { ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:41:11: Error: Superclass has no getter named 'missingSuperMethod'. super.missingSuperMethod; - ^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:42:11: Error: Superclass has no getter named 'missingSuperIndex'. super.missingSuperIndex[42]; ^^^^^^^^^^^^^^^^^"{}.[](42); @@ -292,7 +292,7 @@ abstract class Mixin extends self::Super /*isMixinDeclaration*/ { ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:53:11: Error: Member not found: 'missingStaticMethod'. Super.missingStaticMethod; - ^^^^^^^^^^^^^^^^^^^"; + ^^^^^^^^^^^^^^^^^^^"; invalid-expression "pkg/front_end/testcases/general/missing_static_super.dart:54:11: Error: Member not found: 'missingStaticIndex'. Super.missingStaticIndex[42]; ^^^^^^^^^^^^^^^^^^"{}.[](42); diff --git a/tests/language/dot_shorthands/type_parameter/type_parameter_error_test.dart b/tests/language/dot_shorthands/type_parameter/type_parameter_error_test.dart index 0ccabe13fa2..89ded987133 100644 --- a/tests/language/dot_shorthands/type_parameter/type_parameter_error_test.dart +++ b/tests/language/dot_shorthands/type_parameter/type_parameter_error_test.dart @@ -9,6 +9,13 @@ import '../dot_shorthand_helper.dart'; +class C { + C(); + C.named(); +} + +extension type ET(T v) {} + void main() { StaticMember s = .memberType('s'); // ^ @@ -31,6 +38,17 @@ void main() { // ^^^ // [analyzer] unspecified // [cfe] The static getter or field 'new' isn't defined for the type 'UnnamedConstructorTypeParameters Function()'. - // ^ - // [cfe] The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'. + + C newTearoff = .new; + // ^^^ + // [analyzer] unspecified + // [cfe] A dot shorthand constructor invocation can't have type arguments. + C namedTearoff = .new; + // ^^^ + // [analyzer] unspecified + // [cfe] A dot shorthand constructor invocation can't have type arguments. + ET e = .new; + // ^^^ + // [analyzer] unspecified + // [cfe] A dot shorthand constructor invocation can't have type arguments. }