mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:49:47 +00:00
[cfe] Check for misplaced type arguments on implicit creation expression
Change-Id: Ic3436f2bce0369d0efad9946cbbdae7c6bf334b9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218400 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
parent
12bf51a466
commit
44e35b1daa
|
@ -810,8 +810,8 @@ class ForwardingListener implements Listener {
|
|||
}
|
||||
|
||||
@override
|
||||
void endImplicitCreationExpression(Token token) {
|
||||
listener?.endImplicitCreationExpression(token);
|
||||
void endImplicitCreationExpression(Token token, Token openAngleBracket) {
|
||||
listener?.endImplicitCreationExpression(token, openAngleBracket);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -743,7 +743,7 @@ class Listener implements UnescapeErrorListener {
|
|||
|
||||
void beginImplicitCreationExpression(Token token) {}
|
||||
|
||||
void endImplicitCreationExpression(Token token) {
|
||||
void endImplicitCreationExpression(Token token, Token openAngleBracket) {
|
||||
logEvent("ImplicitCreationExpression");
|
||||
}
|
||||
|
||||
|
|
|
@ -5404,7 +5404,8 @@ class Parser {
|
|||
Token afterPeriod = afterTypeArguments.next!;
|
||||
if (_isNewOrIdentifier(afterPeriod) &&
|
||||
optional('(', afterPeriod.next!)) {
|
||||
return parseImplicitCreationExpression(token, typeArg);
|
||||
return parseImplicitCreationExpression(
|
||||
token, identifier.next!, typeArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6057,13 +6058,13 @@ class Parser {
|
|||
}
|
||||
|
||||
Token parseImplicitCreationExpression(
|
||||
Token token, TypeParamOrArgInfo typeArg) {
|
||||
Token begin = token;
|
||||
listener.beginImplicitCreationExpression(token);
|
||||
Token token, Token openAngleBracket, TypeParamOrArgInfo typeArg) {
|
||||
Token begin = token.next!; // This is the class name.
|
||||
listener.beginImplicitCreationExpression(begin);
|
||||
token = parseConstructorReference(
|
||||
token, ConstructorReferenceContext.Implicit, typeArg);
|
||||
token = parseConstructorInvocationArguments(token);
|
||||
listener.endImplicitCreationExpression(begin);
|
||||
listener.endImplicitCreationExpression(begin, openAngleBracket);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
|
|
@ -1664,7 +1664,7 @@ class AstBuilder extends StackListener {
|
|||
}
|
||||
|
||||
@override
|
||||
void endImplicitCreationExpression(Token token) {
|
||||
void endImplicitCreationExpression(Token token, Token openAngleBracket) {
|
||||
debugEvent("ImplicitCreationExpression");
|
||||
|
||||
_handleInstanceCreation(null);
|
||||
|
|
|
@ -4948,6 +4948,14 @@ class BodyBuilder extends ScopeListener<JumpTarget>
|
|||
if (enableConstructorTearOffsInLibrary && inImplicitCreationContext) {
|
||||
Expression receiver = receiverFunction();
|
||||
if (typeArguments != null) {
|
||||
if (receiver is StaticTearOff &&
|
||||
(receiver.target.isFactory ||
|
||||
isTearOffLowering(receiver.target)) ||
|
||||
receiver is ConstructorTearOff ||
|
||||
receiver is RedirectingFactoryTearOff) {
|
||||
return buildProblem(fasta.messageConstructorTearOffWithTypeArguments,
|
||||
instantiationOffset, noLength);
|
||||
}
|
||||
receiver = forest.createInstantiation(
|
||||
instantiationOffset,
|
||||
receiver,
|
||||
|
@ -4974,10 +4982,10 @@ class BodyBuilder extends ScopeListener<JumpTarget>
|
|||
}
|
||||
|
||||
@override
|
||||
void endImplicitCreationExpression(Token token) {
|
||||
void endImplicitCreationExpression(Token token, Token openAngleBracket) {
|
||||
debugEvent("ImplicitCreationExpression");
|
||||
_buildConstructorReferenceInvocation(
|
||||
token.next!, token.offset, Constness.implicit,
|
||||
token, openAngleBracket.offset, Constness.implicit,
|
||||
inMetadata: false, inImplicitCreationContext: true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1172,11 +1172,12 @@ abstract class AbstractDirectParserASTListener implements Listener {
|
|||
}
|
||||
|
||||
@override
|
||||
void endImplicitCreationExpression(Token token) {
|
||||
void endImplicitCreationExpression(Token token, Token openAngleBracket) {
|
||||
DirectParserASTContentImplicitCreationExpressionEnd data =
|
||||
new DirectParserASTContentImplicitCreationExpressionEnd(
|
||||
DirectParserASTType.END,
|
||||
token: token);
|
||||
token: token,
|
||||
openAngleBracket: openAngleBracket);
|
||||
seen(data);
|
||||
}
|
||||
|
||||
|
@ -4782,14 +4783,16 @@ class DirectParserASTContentImplicitCreationExpressionBegin
|
|||
class DirectParserASTContentImplicitCreationExpressionEnd
|
||||
extends DirectParserASTContent {
|
||||
final Token token;
|
||||
final Token openAngleBracket;
|
||||
|
||||
DirectParserASTContentImplicitCreationExpressionEnd(DirectParserASTType type,
|
||||
{required this.token})
|
||||
{required this.token, required this.openAngleBracket})
|
||||
: super("ImplicitCreationExpression", type);
|
||||
|
||||
@override
|
||||
Map<String, Object?> get deprecatedArguments => {
|
||||
"token": token,
|
||||
"openAngleBracket": openAngleBracket,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ beginCompilationUnit(var)
|
|||
handleNoType(var)
|
||||
handleIdentifier(typeArgs_period_methodInvocation, topLevelVariableDeclaration)
|
||||
beginFieldInitializer(=)
|
||||
beginImplicitCreationExpression(=)
|
||||
beginImplicitCreationExpression(f)
|
||||
handleIdentifier(f, constructorReference)
|
||||
beginConstructorReference(f)
|
||||
beginTypeArguments(<)
|
||||
|
@ -308,7 +308,7 @@ beginCompilationUnit(var)
|
|||
endConstructorReference(f, ., (, ConstructorReferenceContext.Implicit)
|
||||
beginArguments(()
|
||||
endArguments(0, (, ))
|
||||
endImplicitCreationExpression(=)
|
||||
endImplicitCreationExpression(f, <)
|
||||
endFieldInitializer(=, ;)
|
||||
endTopLevelFields(null, null, null, null, var, 1, var, ;)
|
||||
endTopLevelDeclaration(var)
|
||||
|
|
|
@ -396,8 +396,8 @@ parseUnit(var)
|
|||
parseExpression(=)
|
||||
parsePrecedenceExpression(=, 1, true)
|
||||
parseUnaryExpression(=, true)
|
||||
parseImplicitCreationExpression(=, Instance of 'ComplexTypeParamOrArgInfo')
|
||||
listener: beginImplicitCreationExpression(=)
|
||||
parseImplicitCreationExpression(=, <, Instance of 'ComplexTypeParamOrArgInfo')
|
||||
listener: beginImplicitCreationExpression(f)
|
||||
parseConstructorReference(=, ConstructorReferenceContext.Implicit, Instance of 'ComplexTypeParamOrArgInfo')
|
||||
ensureIdentifier(=, constructorReference)
|
||||
listener: handleIdentifier(f, constructorReference)
|
||||
|
@ -418,7 +418,7 @@ parseUnit(var)
|
|||
parseArgumentsRest(()
|
||||
listener: beginArguments(()
|
||||
listener: endArguments(0, (, ))
|
||||
listener: endImplicitCreationExpression(=)
|
||||
listener: endImplicitCreationExpression(f, <)
|
||||
listener: endFieldInitializer(=, ;)
|
||||
listener: endTopLevelFields(null, null, null, null, var, 1, var, ;)
|
||||
listener: endTopLevelDeclaration(var)
|
||||
|
|
|
@ -545,7 +545,7 @@ beginCompilationUnit(class)
|
|||
handleNoType(var)
|
||||
handleIdentifier(constructor_invocation_implicit_generic, topLevelVariableDeclaration)
|
||||
beginFieldInitializer(=)
|
||||
beginImplicitCreationExpression(=)
|
||||
beginImplicitCreationExpression(C)
|
||||
handleIdentifier(C, constructorReference)
|
||||
beginConstructorReference(C)
|
||||
beginTypeArguments(<)
|
||||
|
@ -558,7 +558,7 @@ beginCompilationUnit(class)
|
|||
endConstructorReference(C, ., (, ConstructorReferenceContext.Implicit)
|
||||
beginArguments(()
|
||||
endArguments(0, (, ))
|
||||
endImplicitCreationExpression(=)
|
||||
endImplicitCreationExpression(C, <)
|
||||
endFieldInitializer(=, ;)
|
||||
endTopLevelFields(null, null, null, null, var, 1, var, ;)
|
||||
endTopLevelDeclaration(var)
|
||||
|
@ -595,7 +595,7 @@ beginCompilationUnit(class)
|
|||
handleNoType(var)
|
||||
handleIdentifier(constructor_invocation_implicit_prefixed_generic, topLevelVariableDeclaration)
|
||||
beginFieldInitializer(=)
|
||||
beginImplicitCreationExpression(=)
|
||||
beginImplicitCreationExpression(prefix)
|
||||
handleIdentifier(prefix, constructorReference)
|
||||
beginConstructorReference(prefix)
|
||||
handleIdentifier(C, constructorReferenceContinuation)
|
||||
|
@ -610,7 +610,7 @@ beginCompilationUnit(class)
|
|||
endConstructorReference(prefix, ., (, ConstructorReferenceContext.Implicit)
|
||||
beginArguments(()
|
||||
endArguments(0, (, ))
|
||||
endImplicitCreationExpression(=)
|
||||
endImplicitCreationExpression(prefix, <)
|
||||
endFieldInitializer(=, ;)
|
||||
endTopLevelFields(null, null, null, null, var, 1, var, ;)
|
||||
endTopLevelDeclaration(var)
|
||||
|
|
|
@ -1028,8 +1028,8 @@ parseUnit(class)
|
|||
parseExpression(=)
|
||||
parsePrecedenceExpression(=, 1, true)
|
||||
parseUnaryExpression(=, true)
|
||||
parseImplicitCreationExpression(=, Instance of 'SimpleTypeArgument1')
|
||||
listener: beginImplicitCreationExpression(=)
|
||||
parseImplicitCreationExpression(=, <, Instance of 'SimpleTypeArgument1')
|
||||
listener: beginImplicitCreationExpression(C)
|
||||
parseConstructorReference(=, ConstructorReferenceContext.Implicit, Instance of 'SimpleTypeArgument1')
|
||||
ensureIdentifier(=, constructorReference)
|
||||
listener: handleIdentifier(C, constructorReference)
|
||||
|
@ -1049,7 +1049,7 @@ parseUnit(class)
|
|||
parseArgumentsRest(()
|
||||
listener: beginArguments(()
|
||||
listener: endArguments(0, (, ))
|
||||
listener: endImplicitCreationExpression(=)
|
||||
listener: endImplicitCreationExpression(C, <)
|
||||
listener: endFieldInitializer(=, ;)
|
||||
listener: endTopLevelFields(null, null, null, null, var, 1, var, ;)
|
||||
listener: endTopLevelDeclaration(var)
|
||||
|
@ -1126,8 +1126,8 @@ parseUnit(class)
|
|||
parseExpression(=)
|
||||
parsePrecedenceExpression(=, 1, true)
|
||||
parseUnaryExpression(=, true)
|
||||
parseImplicitCreationExpression(=, Instance of 'SimpleTypeArgument1')
|
||||
listener: beginImplicitCreationExpression(=)
|
||||
parseImplicitCreationExpression(=, <, Instance of 'SimpleTypeArgument1')
|
||||
listener: beginImplicitCreationExpression(prefix)
|
||||
parseConstructorReference(=, ConstructorReferenceContext.Implicit, Instance of 'SimpleTypeArgument1')
|
||||
ensureIdentifier(=, constructorReference)
|
||||
listener: handleIdentifier(prefix, constructorReference)
|
||||
|
@ -1151,7 +1151,7 @@ parseUnit(class)
|
|||
parseArgumentsRest(()
|
||||
listener: beginArguments(()
|
||||
listener: endArguments(0, (, ))
|
||||
listener: endImplicitCreationExpression(=)
|
||||
listener: endImplicitCreationExpression(prefix, <)
|
||||
listener: endFieldInitializer(=, ;)
|
||||
listener: endTopLevelFields(null, null, null, null, var, 1, var, ;)
|
||||
listener: endTopLevelDeclaration(var)
|
||||
|
|
|
@ -1086,10 +1086,11 @@ class ParserTestListener implements Listener {
|
|||
}
|
||||
|
||||
@override
|
||||
void endImplicitCreationExpression(Token token) {
|
||||
void endImplicitCreationExpression(Token token, Token openAngleBracket) {
|
||||
indent--;
|
||||
seen(token);
|
||||
doPrint('endImplicitCreationExpression(' '$token)');
|
||||
seen(openAngleBracket);
|
||||
doPrint('endImplicitCreationExpression(' '$token, ' '$openAngleBracket)');
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1651,10 +1651,14 @@ class TestParser extends Parser {
|
|||
|
||||
@override
|
||||
Token parseImplicitCreationExpression(
|
||||
Token token, TypeParamOrArgInfo typeArg) {
|
||||
doPrint('parseImplicitCreationExpression(' '$token, ' '$typeArg)');
|
||||
Token token, Token openAngleBracket, TypeParamOrArgInfo typeArg) {
|
||||
doPrint('parseImplicitCreationExpression('
|
||||
'$token, '
|
||||
'$openAngleBracket, '
|
||||
'$typeArg)');
|
||||
indent++;
|
||||
var result = super.parseImplicitCreationExpression(token, typeArg);
|
||||
var result =
|
||||
super.parseImplicitCreationExpression(token, openAngleBracket, typeArg);
|
||||
indent--;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ extension FunctionApplier on Function {
|
|||
}
|
||||
|
||||
test() {
|
||||
A.named<int>.toString();
|
||||
A.named<int>.toString(); // error
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
// Try removing the type arguments or placing them after the class name.
|
||||
// A.named<int>.toString(); // error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
|
@ -27,30 +35,33 @@ static method FunctionApplier|applyAndPrint(lowered final core::Function #this,
|
|||
static method FunctionApplier|get#applyAndPrint(lowered final core::Function #this) → (core::List<core::Object?>) → void
|
||||
return (core::List<core::Object?> positionalArguments) → void => self::FunctionApplier|applyAndPrint(#this, positionalArguments);
|
||||
static method test() → dynamic {
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
invalid-expression "pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
Try removing the type arguments or placing them after the class name.
|
||||
A.named<int>.toString(); // error
|
||||
^";
|
||||
}
|
||||
static method main() → void {
|
||||
self::A<dynamic> a = new self::A::•<dynamic>();
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::int>, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::String>, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C5, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C6, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C8, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C9, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C5, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C6, <core::Object?>["three"]);
|
||||
#C2.{core::Object::toString}(){() → core::String};
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
self::FunctionApplier|applyAndPrint(#C3, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C4, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C6, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C7, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C3, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C4, <core::Object?>["three"]);
|
||||
#C8.{core::Object::toString}(){() → core::String};
|
||||
#C9.{core::Object::toString}(){() → core::String};
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = <core::Symbol, dynamic>{)
|
||||
#C2 = constructor-tearoff self::A::named
|
||||
#C2 = static-tearoff self::A::n
|
||||
#C3 = instantiation #C2 <core::int>
|
||||
#C4 = static-tearoff self::A::n
|
||||
#C5 = instantiation #C4 <core::int>
|
||||
#C6 = instantiation #C4 <core::String>
|
||||
#C7 = static-tearoff self::m
|
||||
#C8 = instantiation #C7 <core::int>
|
||||
#C9 = instantiation #C7 <core::String>
|
||||
#C4 = instantiation #C2 <core::String>
|
||||
#C5 = static-tearoff self::m
|
||||
#C6 = instantiation #C5 <core::int>
|
||||
#C7 = instantiation #C5 <core::String>
|
||||
#C8 = constructor-tearoff self::A::named
|
||||
#C9 = instantiation #C8 <core::int>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
// Try removing the type arguments or placing them after the class name.
|
||||
// A.named<int>.toString(); // error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
|
@ -27,30 +35,33 @@ static method FunctionApplier|applyAndPrint(lowered final core::Function #this,
|
|||
static method FunctionApplier|get#applyAndPrint(lowered final core::Function #this) → (core::List<core::Object?>) → void
|
||||
return (core::List<core::Object?> positionalArguments) → void => self::FunctionApplier|applyAndPrint(#this, positionalArguments);
|
||||
static method test() → dynamic {
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
invalid-expression "pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
Try removing the type arguments or placing them after the class name.
|
||||
A.named<int>.toString(); // error
|
||||
^";
|
||||
}
|
||||
static method main() → void {
|
||||
self::A<dynamic> a = new self::A::•<dynamic>();
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::int>, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::String>, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C5, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C6, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C8, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C9, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C5, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C6, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
#C2.{core::Object::toString}(){() → core::String};
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
self::FunctionApplier|applyAndPrint(#C3, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C4, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C6, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C7, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C3, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C4, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
#C8.{core::Object::toString}(){() → core::String};
|
||||
#C9.{core::Object::toString}(){() → core::String};
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = <core::Symbol, dynamic>{)
|
||||
#C2 = constructor-tearoff self::A::named
|
||||
#C2 = static-tearoff self::A::n
|
||||
#C3 = instantiation #C2 <core::int>
|
||||
#C4 = static-tearoff self::A::n
|
||||
#C5 = instantiation #C4 <core::int>
|
||||
#C6 = instantiation #C4 <core::String>
|
||||
#C7 = static-tearoff self::m
|
||||
#C8 = instantiation #C7 <core::int>
|
||||
#C9 = instantiation #C7 <core::String>
|
||||
#C4 = instantiation #C2 <core::String>
|
||||
#C5 = static-tearoff self::m
|
||||
#C6 = instantiation #C5 <core::int>
|
||||
#C7 = instantiation #C5 <core::String>
|
||||
#C8 = constructor-tearoff self::A::named
|
||||
#C9 = instantiation #C8 <core::int>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
// Try removing the type arguments or placing them after the class name.
|
||||
// A.named<int>.toString(); // error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
|
@ -27,30 +35,33 @@ static method FunctionApplier|applyAndPrint(lowered final core::Function #this,
|
|||
static method FunctionApplier|get#applyAndPrint(lowered final core::Function #this) → (core::List<core::Object?>) → void
|
||||
return (core::List<core::Object?> positionalArguments) → void => self::FunctionApplier|applyAndPrint(#this, positionalArguments);
|
||||
static method test() → dynamic {
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
invalid-expression "pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
Try removing the type arguments or placing them after the class name.
|
||||
A.named<int>.toString(); // error
|
||||
^";
|
||||
}
|
||||
static method main() → void {
|
||||
self::A<dynamic> a = new self::A::•<dynamic>();
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::int>, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::String>, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C5, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C6, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C8, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C9, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C5, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C6, <core::Object?>["three"]);
|
||||
#C2.{core::Object::toString}(){() → core::String};
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
self::FunctionApplier|applyAndPrint(#C3, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C4, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C6, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C7, <core::Object?>["three"]);
|
||||
self::FunctionApplier|applyAndPrint(#C3, <core::Object?>[2]);
|
||||
self::FunctionApplier|applyAndPrint(#C4, <core::Object?>["three"]);
|
||||
#C8.{core::Object::toString}(){() → core::String};
|
||||
#C9.{core::Object::toString}(){() → core::String};
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = <core::Symbol*, dynamic>{)
|
||||
#C2 = constructor-tearoff self::A::named
|
||||
#C2 = static-tearoff self::A::n
|
||||
#C3 = instantiation #C2 <core::int*>
|
||||
#C4 = static-tearoff self::A::n
|
||||
#C5 = instantiation #C4 <core::int*>
|
||||
#C6 = instantiation #C4 <core::String*>
|
||||
#C7 = static-tearoff self::m
|
||||
#C8 = instantiation #C7 <core::int*>
|
||||
#C9 = instantiation #C7 <core::String*>
|
||||
#C4 = instantiation #C2 <core::String*>
|
||||
#C5 = static-tearoff self::m
|
||||
#C6 = instantiation #C5 <core::int*>
|
||||
#C7 = instantiation #C5 <core::String*>
|
||||
#C8 = constructor-tearoff self::A::named
|
||||
#C9 = instantiation #C8 <core::int*>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
// Try removing the type arguments or placing them after the class name.
|
||||
// A.named<int>.toString(); // error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
|
@ -27,30 +35,33 @@ static method FunctionApplier|applyAndPrint(lowered final core::Function #this,
|
|||
static method FunctionApplier|get#applyAndPrint(lowered final core::Function #this) → (core::List<core::Object?>) → void
|
||||
return (core::List<core::Object?> positionalArguments) → void => self::FunctionApplier|applyAndPrint(#this, positionalArguments);
|
||||
static method test() → dynamic {
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
invalid-expression "pkg/front_end/testcases/constructor_tearoffs/issue46719.dart:24:10: Error: A constructor tear-off can't have type arguments after the constructor name.
|
||||
Try removing the type arguments or placing them after the class name.
|
||||
A.named<int>.toString(); // error
|
||||
^";
|
||||
}
|
||||
static method main() → void {
|
||||
self::A<dynamic> a = new self::A::•<dynamic>();
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::int>, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(a.{self::A::m}{<X extends core::Object? = dynamic>(X%) → core::List<X%>}<core::String>, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C5, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C6, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C8, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C9, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C5, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C6, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
#C2.{core::Object::toString}(){() → core::String};
|
||||
#C3.{core::Object::toString}(){() → core::String};
|
||||
self::FunctionApplier|applyAndPrint(#C3, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C4, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C6, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C7, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
self::FunctionApplier|applyAndPrint(#C3, core::_GrowableList::_literal1<core::Object?>(2));
|
||||
self::FunctionApplier|applyAndPrint(#C4, core::_GrowableList::_literal1<core::Object?>("three"));
|
||||
#C8.{core::Object::toString}(){() → core::String};
|
||||
#C9.{core::Object::toString}(){() → core::String};
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = <core::Symbol*, dynamic>{)
|
||||
#C2 = constructor-tearoff self::A::named
|
||||
#C2 = static-tearoff self::A::n
|
||||
#C3 = instantiation #C2 <core::int*>
|
||||
#C4 = static-tearoff self::A::n
|
||||
#C5 = instantiation #C4 <core::int*>
|
||||
#C6 = instantiation #C4 <core::String*>
|
||||
#C7 = static-tearoff self::m
|
||||
#C8 = instantiation #C7 <core::int*>
|
||||
#C9 = instantiation #C7 <core::String*>
|
||||
#C4 = instantiation #C2 <core::String*>
|
||||
#C5 = static-tearoff self::m
|
||||
#C6 = instantiation #C5 <core::int*>
|
||||
#C7 = instantiation #C5 <core::String*>
|
||||
#C8 = constructor-tearoff self::A::named
|
||||
#C9 = instantiation #C8 <core::int*>
|
||||
}
|
||||
|
|
|
@ -97,8 +97,7 @@ main() {
|
|||
Foo.bar<int>.baz();
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
|
||||
// ^
|
||||
// [cfe] The method 'baz' isn't defined for the class 'Foo<int> Function()'.
|
||||
// [cfe] A constructor tear-off can't have type arguments after the constructor name.
|
||||
Foo.bar.baz<int>();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
|
||||
|
|
Loading…
Reference in a new issue