mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:01:42 +00:00
Reformat untouched files.
R=sigmund@google.com Review-Url: https://codereview.chromium.org/2990223002 .
This commit is contained in:
parent
aaf67e5050
commit
5fe6282ec0
|
@ -2102,9 +2102,8 @@ part of lib.foo;
|
|||
"both '#{canonicalUri1}' and '#{canonicalUri2}'."),
|
||||
|
||||
// This is used as an exception.
|
||||
MessageKind.INVALID_SOURCE_FILE_LOCATION: const MessageTemplate(
|
||||
MessageKind.INVALID_SOURCE_FILE_LOCATION,
|
||||
'''
|
||||
MessageKind.INVALID_SOURCE_FILE_LOCATION:
|
||||
const MessageTemplate(MessageKind.INVALID_SOURCE_FILE_LOCATION, '''
|
||||
Invalid offset (#{offset}) in source map.
|
||||
File: #{fileName}
|
||||
Length: #{length}'''),
|
||||
|
@ -3207,9 +3206,8 @@ main() => new A();
|
|||
MessageKind.COMPILER_CRASHED,
|
||||
"The compiler crashed when compiling this element."),
|
||||
|
||||
MessageKind.PLEASE_REPORT_THE_CRASH: const MessageTemplate(
|
||||
MessageKind.PLEASE_REPORT_THE_CRASH,
|
||||
'''
|
||||
MessageKind.PLEASE_REPORT_THE_CRASH:
|
||||
const MessageTemplate(MessageKind.PLEASE_REPORT_THE_CRASH, '''
|
||||
The compiler is broken.
|
||||
|
||||
When compiling the above element, the compiler crashed. It is not
|
||||
|
|
|
@ -1767,16 +1767,14 @@ class AsyncRewriter extends AsyncRewriterBase {
|
|||
|
||||
@override
|
||||
js.Statement awaitStatement(js.Expression value) {
|
||||
return js.js.statement(
|
||||
"""
|
||||
return js.js.statement("""
|
||||
return #asyncHelper(#value,
|
||||
#bodyName);
|
||||
""",
|
||||
{
|
||||
"asyncHelper": asyncAwait,
|
||||
"value": value,
|
||||
"bodyName": bodyName,
|
||||
});
|
||||
""", {
|
||||
"asyncHelper": asyncAwait,
|
||||
"value": value,
|
||||
"bodyName": bodyName,
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1785,8 +1783,7 @@ class AsyncRewriter extends AsyncRewriterBase {
|
|||
js.Statement rewrittenBody,
|
||||
js.VariableDeclarationList variableDeclarations,
|
||||
SourceInformation sourceInformation) {
|
||||
return js.js(
|
||||
"""
|
||||
return js.js("""
|
||||
function (#parameters) {
|
||||
#variableDeclarations;
|
||||
var #bodyName = #wrapBody(function (#errorCode, #result) {
|
||||
|
@ -1800,24 +1797,23 @@ class AsyncRewriter extends AsyncRewriterBase {
|
|||
#rewrittenBody;
|
||||
});
|
||||
return #asyncStart(#bodyName, #completer);
|
||||
}""",
|
||||
{
|
||||
"parameters": parameters,
|
||||
"variableDeclarations": variableDeclarations,
|
||||
"ERROR": js.number(error_codes.ERROR),
|
||||
"rewrittenBody": rewrittenBody,
|
||||
"bodyName": bodyName,
|
||||
"currentError": currentError,
|
||||
"goto": goto,
|
||||
"handler": handler,
|
||||
"errorCode": errorCodeName,
|
||||
"result": resultName,
|
||||
"asyncStart": asyncStart,
|
||||
"asyncRethrow": asyncRethrow,
|
||||
"hasHandlerLabels": hasHandlerLabels,
|
||||
"completer": completer,
|
||||
"wrapBody": wrapBody,
|
||||
}).withSourceInformation(sourceInformation);
|
||||
}""", {
|
||||
"parameters": parameters,
|
||||
"variableDeclarations": variableDeclarations,
|
||||
"ERROR": js.number(error_codes.ERROR),
|
||||
"rewrittenBody": rewrittenBody,
|
||||
"bodyName": bodyName,
|
||||
"currentError": currentError,
|
||||
"goto": goto,
|
||||
"handler": handler,
|
||||
"errorCode": errorCodeName,
|
||||
"result": resultName,
|
||||
"asyncStart": asyncStart,
|
||||
"asyncRethrow": asyncRethrow,
|
||||
"hasHandlerLabels": hasHandlerLabels,
|
||||
"completer": completer,
|
||||
"wrapBody": wrapBody,
|
||||
}).withSourceInformation(sourceInformation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1886,8 +1882,7 @@ class SyncStarRewriter extends AsyncRewriterBase {
|
|||
}
|
||||
js.VariableDeclarationList copyParameters =
|
||||
new js.VariableDeclarationList(declarations);
|
||||
return js.js(
|
||||
"""
|
||||
return js.js("""
|
||||
function (#renamedParameters) {
|
||||
if (#needsThis)
|
||||
var #self = this;
|
||||
|
@ -1905,24 +1900,23 @@ class SyncStarRewriter extends AsyncRewriterBase {
|
|||
};
|
||||
});
|
||||
}
|
||||
""",
|
||||
{
|
||||
"renamedParameters": renamedParameters,
|
||||
"needsThis": analysis.hasThis,
|
||||
"helperBody": rewrittenBody,
|
||||
"hasParameters": parameters.isNotEmpty,
|
||||
"copyParameters": copyParameters,
|
||||
"varDecl": variableDeclarations,
|
||||
"errorCode": errorCodeName,
|
||||
"iterableFactory": iterableFactory,
|
||||
"body": bodyName,
|
||||
"self": selfName,
|
||||
"result": resultName,
|
||||
"goto": goto,
|
||||
"handler": handler,
|
||||
"currentError": currentErrorName,
|
||||
"ERROR": js.number(error_codes.ERROR),
|
||||
}).withSourceInformation(sourceInformation);
|
||||
""", {
|
||||
"renamedParameters": renamedParameters,
|
||||
"needsThis": analysis.hasThis,
|
||||
"helperBody": rewrittenBody,
|
||||
"hasParameters": parameters.isNotEmpty,
|
||||
"copyParameters": copyParameters,
|
||||
"varDecl": variableDeclarations,
|
||||
"errorCode": errorCodeName,
|
||||
"iterableFactory": iterableFactory,
|
||||
"body": bodyName,
|
||||
"self": selfName,
|
||||
"result": resultName,
|
||||
"goto": goto,
|
||||
"handler": handler,
|
||||
"currentError": currentErrorName,
|
||||
"ERROR": js.number(error_codes.ERROR),
|
||||
}).withSourceInformation(sourceInformation);
|
||||
}
|
||||
|
||||
void addErrorExit() {
|
||||
|
@ -2043,18 +2037,15 @@ class AsyncStarRewriter extends AsyncRewriterBase {
|
|||
nextWhenCanceled,
|
||||
new js.ArrayInitializer(enclosingFinallyLabels.map(js.number).toList())
|
||||
]));
|
||||
addStatement(js.js.statement(
|
||||
"""
|
||||
addStatement(js.js.statement("""
|
||||
return #asyncStarHelper(#yieldExpression(#expression), #bodyName,
|
||||
#controller);""",
|
||||
{
|
||||
"asyncStarHelper": asyncStarHelper,
|
||||
"yieldExpression":
|
||||
node.hasStar ? yieldStarExpression : yieldExpression,
|
||||
"expression": expression,
|
||||
"bodyName": bodyName,
|
||||
"controller": controllerName,
|
||||
}));
|
||||
#controller);""", {
|
||||
"asyncStarHelper": asyncStarHelper,
|
||||
"yieldExpression": node.hasStar ? yieldStarExpression : yieldExpression,
|
||||
"expression": expression,
|
||||
"bodyName": bodyName,
|
||||
"controller": controllerName,
|
||||
}));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -2063,8 +2054,7 @@ class AsyncStarRewriter extends AsyncRewriterBase {
|
|||
js.Statement rewrittenBody,
|
||||
js.VariableDeclarationList variableDeclarations,
|
||||
SourceInformation sourceInformation) {
|
||||
return js.js(
|
||||
"""
|
||||
return js.js("""
|
||||
function (#parameters) {
|
||||
var #bodyName = #wrapBody(function (#errorCode, #result) {
|
||||
if (#hasYield) {
|
||||
|
@ -2087,26 +2077,25 @@ class AsyncStarRewriter extends AsyncRewriterBase {
|
|||
});
|
||||
#variableDeclarations;
|
||||
return #streamOfController(#controller);
|
||||
}""",
|
||||
{
|
||||
"parameters": parameters,
|
||||
"variableDeclarations": variableDeclarations,
|
||||
"STREAM_WAS_CANCELED": js.number(error_codes.STREAM_WAS_CANCELED),
|
||||
"ERROR": js.number(error_codes.ERROR),
|
||||
"hasYield": analysis.hasYield,
|
||||
"rewrittenBody": rewrittenBody,
|
||||
"bodyName": bodyName,
|
||||
"currentError": currentError,
|
||||
"goto": goto,
|
||||
"handler": handler,
|
||||
"next": next,
|
||||
"nextWhenCanceled": nextWhenCanceled,
|
||||
"errorCode": errorCodeName,
|
||||
"result": resultName,
|
||||
"streamOfController": streamOfController,
|
||||
"controller": controllerName,
|
||||
"wrapBody": wrapBody,
|
||||
}).withSourceInformation(sourceInformation);
|
||||
}""", {
|
||||
"parameters": parameters,
|
||||
"variableDeclarations": variableDeclarations,
|
||||
"STREAM_WAS_CANCELED": js.number(error_codes.STREAM_WAS_CANCELED),
|
||||
"ERROR": js.number(error_codes.ERROR),
|
||||
"hasYield": analysis.hasYield,
|
||||
"rewrittenBody": rewrittenBody,
|
||||
"bodyName": bodyName,
|
||||
"currentError": currentError,
|
||||
"goto": goto,
|
||||
"handler": handler,
|
||||
"next": next,
|
||||
"nextWhenCanceled": nextWhenCanceled,
|
||||
"errorCode": errorCodeName,
|
||||
"result": resultName,
|
||||
"streamOfController": streamOfController,
|
||||
"controller": controllerName,
|
||||
"wrapBody": wrapBody,
|
||||
}).withSourceInformation(sourceInformation);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -2155,18 +2144,16 @@ class AsyncStarRewriter extends AsyncRewriterBase {
|
|||
|
||||
@override
|
||||
js.Statement awaitStatement(js.Expression value) {
|
||||
return js.js.statement(
|
||||
"""
|
||||
return js.js.statement("""
|
||||
return #asyncHelper(#value,
|
||||
#bodyName,
|
||||
#controller);
|
||||
""",
|
||||
{
|
||||
"asyncHelper": asyncStarHelper,
|
||||
"value": value,
|
||||
"bodyName": bodyName,
|
||||
"controller": controllerName
|
||||
});
|
||||
""", {
|
||||
"asyncHelper": asyncStarHelper,
|
||||
"value": value,
|
||||
"bodyName": bodyName,
|
||||
"controller": controllerName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -189,26 +189,23 @@ class ClassStubGenerator {
|
|||
|
||||
assert(_interceptorData.isInterceptedName(Identifiers.noSuchMethod_));
|
||||
bool isIntercepted = _interceptorData.isInterceptedName(selector.name);
|
||||
jsAst.Expression expression = js(
|
||||
'''this.#noSuchMethodName(#receiver,
|
||||
jsAst.Expression expression = js('''this.#noSuchMethodName(#receiver,
|
||||
#createInvocationMirror(#methodName,
|
||||
#internalName,
|
||||
#type,
|
||||
#arguments,
|
||||
#namedArguments))''',
|
||||
{
|
||||
'receiver': isIntercepted ? r'$receiver' : 'this',
|
||||
'noSuchMethodName': _namer.noSuchMethodName,
|
||||
'createInvocationMirror': _emitter
|
||||
.staticFunctionAccess(_commonElements.createInvocationMirror),
|
||||
'methodName':
|
||||
js.quoteName(enableMinification ? internalName : methodName),
|
||||
'internalName': js.quoteName(internalName),
|
||||
'type': js.number(type),
|
||||
'arguments':
|
||||
new jsAst.ArrayInitializer(parameterNames.map(js).toList()),
|
||||
'namedArguments': new jsAst.ArrayInitializer(argNames)
|
||||
});
|
||||
#namedArguments))''', {
|
||||
'receiver': isIntercepted ? r'$receiver' : 'this',
|
||||
'noSuchMethodName': _namer.noSuchMethodName,
|
||||
'createInvocationMirror':
|
||||
_emitter.staticFunctionAccess(_commonElements.createInvocationMirror),
|
||||
'methodName':
|
||||
js.quoteName(enableMinification ? internalName : methodName),
|
||||
'internalName': js.quoteName(internalName),
|
||||
'type': js.number(type),
|
||||
'arguments': new jsAst.ArrayInitializer(parameterNames.map(js).toList()),
|
||||
'namedArguments': new jsAst.ArrayInitializer(argNames)
|
||||
});
|
||||
|
||||
jsAst.Expression function;
|
||||
if (isIntercepted) {
|
||||
|
@ -260,8 +257,7 @@ List<jsAst.Statement> buildTearOffCode(CompilerOptions options, Emitter emitter,
|
|||
if (!options.useContentSecurityPolicy) {
|
||||
jsAst.Expression tearOffAccessText =
|
||||
new jsAst.UnparsedNode(tearOffAccessExpression, options, false);
|
||||
tearOffGetter = js.statement(
|
||||
'''
|
||||
tearOffGetter = js.statement('''
|
||||
function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
|
||||
return isIntercepted
|
||||
? new Function("funcs", "reflectionInfo", "name",
|
||||
|
@ -278,15 +274,13 @@ function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
|
|||
"this, funcs, reflectionInfo, false, [], name);" +
|
||||
"return new c(this, funcs[0], null, name);" +
|
||||
"}")(funcs, reflectionInfo, name, #tearOffGlobalObject, null);
|
||||
}''',
|
||||
{
|
||||
'tearOffAccessText': tearOffAccessText,
|
||||
'tearOffGlobalObject': tearOffGlobalObject,
|
||||
'tearOffGlobalObjectString': tearOffGlobalObjectString
|
||||
});
|
||||
}''', {
|
||||
'tearOffAccessText': tearOffAccessText,
|
||||
'tearOffGlobalObject': tearOffGlobalObject,
|
||||
'tearOffGlobalObjectString': tearOffGlobalObjectString
|
||||
});
|
||||
} else {
|
||||
tearOffGetter = js.statement(
|
||||
'''
|
||||
tearOffGetter = js.statement('''
|
||||
function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
|
||||
var cache = null;
|
||||
return isIntercepted
|
||||
|
@ -300,12 +294,10 @@ function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
|
|||
this, funcs, reflectionInfo, false, [], name);
|
||||
return new cache(this, funcs[0], null, name);
|
||||
};
|
||||
}''',
|
||||
[tearOffAccessExpression, tearOffAccessExpression]);
|
||||
}''', [tearOffAccessExpression, tearOffAccessExpression]);
|
||||
}
|
||||
|
||||
jsAst.Statement tearOff = js.statement(
|
||||
'''
|
||||
jsAst.Statement tearOff = js.statement('''
|
||||
function tearOff(funcs, reflectionInfo, isStatic, name, isIntercepted) {
|
||||
var cache;
|
||||
return isStatic
|
||||
|
@ -315,8 +307,7 @@ function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
|
|||
return cache;
|
||||
}
|
||||
: tearOffGetter(funcs, reflectionInfo, name, isIntercepted);
|
||||
}''',
|
||||
{'tearOff': tearOffAccessExpression});
|
||||
}''', {'tearOff': tearOffAccessExpression});
|
||||
|
||||
return <jsAst.Statement>[tearOffGetter, tearOff];
|
||||
}
|
||||
|
|
|
@ -577,22 +577,19 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
// constructor-functions and getter/setter functions can be stored in the
|
||||
// library-description table. Setting properties on these can be moved to
|
||||
// finishClasses.
|
||||
return js.statement(
|
||||
r"""
|
||||
return js.statement(r"""
|
||||
#precompiled = function ($collectedClasses$) {
|
||||
#norename;
|
||||
var $desc;
|
||||
#functions;
|
||||
return #result;
|
||||
};""",
|
||||
{
|
||||
'norename': new jsAst.Comment("// ::norenaming:: "),
|
||||
'precompiled':
|
||||
generateEmbeddedGlobalAccess(embeddedNames.PRECOMPILED),
|
||||
'functions': cspPrecompiledFunctionFor(outputUnit),
|
||||
'result': new jsAst.ArrayInitializer(
|
||||
cspPrecompiledConstructorNamesFor(outputUnit))
|
||||
});
|
||||
};""", {
|
||||
'norename': new jsAst.Comment("// ::norenaming:: "),
|
||||
'precompiled': generateEmbeddedGlobalAccess(embeddedNames.PRECOMPILED),
|
||||
'functions': cspPrecompiledFunctionFor(outputUnit),
|
||||
'result': new jsAst.ArrayInitializer(
|
||||
cspPrecompiledConstructorNamesFor(outputUnit))
|
||||
});
|
||||
} else {
|
||||
return js.comment("Constructors are generated at runtime.");
|
||||
}
|
||||
|
@ -671,8 +668,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
needsLazyInitializer = true;
|
||||
List<jsAst.Expression> laziesInfo =
|
||||
buildLaziesInfo(lazyFields, isMainFragment);
|
||||
return js.statement(
|
||||
'''
|
||||
return js.statement('''
|
||||
(function(lazies) {
|
||||
for (var i = 0; i < lazies.length; ) {
|
||||
var fieldName = lazies[i++];
|
||||
|
@ -703,14 +699,13 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
}
|
||||
}
|
||||
})(#laziesInfo)
|
||||
''',
|
||||
{
|
||||
'notMinified': !compiler.options.enableMinification,
|
||||
'laziesInfo': new jsAst.ArrayInitializer(laziesInfo),
|
||||
'lazy': js(lazyInitializerName),
|
||||
'isMainFragment': isMainFragment,
|
||||
'isDeferredFragment': !isMainFragment
|
||||
});
|
||||
''', {
|
||||
'notMinified': !compiler.options.enableMinification,
|
||||
'laziesInfo': new jsAst.ArrayInitializer(laziesInfo),
|
||||
'lazy': js(lazyInitializerName),
|
||||
'isMainFragment': isMainFragment,
|
||||
'isDeferredFragment': !isMainFragment
|
||||
});
|
||||
} else {
|
||||
return js.comment("No lazy statics.");
|
||||
}
|
||||
|
@ -785,8 +780,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
|
||||
jsAst.Statement buildMakeConstantList(bool outputContainsConstantList) {
|
||||
if (outputContainsConstantList) {
|
||||
return js.statement(
|
||||
r'''
|
||||
return js.statement(r'''
|
||||
// Functions are stored in the hidden class and not as properties in
|
||||
// the object. We never actually look at the value, but only want
|
||||
// to know if the property exists.
|
||||
|
@ -794,8 +788,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
list.immutable$list = Array;
|
||||
list.fixed$length = Array;
|
||||
return list;
|
||||
}''',
|
||||
[namer.isolateName, makeConstListProperty]);
|
||||
}''', [namer.isolateName, makeConstListProperty]);
|
||||
} else {
|
||||
return js.comment("Output contains no constant list.");
|
||||
}
|
||||
|
@ -819,18 +812,14 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
if (NativeGenerator
|
||||
.needsIsolateAffinityTagInitialization(_closedWorld.backendUsage)) {
|
||||
parts.add(NativeGenerator.generateIsolateAffinityTagInitialization(
|
||||
_closedWorld.backendUsage,
|
||||
generateEmbeddedGlobalAccess,
|
||||
js(
|
||||
"""
|
||||
_closedWorld.backendUsage, generateEmbeddedGlobalAccess, js("""
|
||||
// On V8, the 'intern' function converts a string to a symbol, which
|
||||
// makes property access much faster.
|
||||
function (s) {
|
||||
var o = {};
|
||||
o[s] = 1;
|
||||
return Object.keys(convertToFastObject(o))[0];
|
||||
}""",
|
||||
[])));
|
||||
}""", [])));
|
||||
}
|
||||
|
||||
parts
|
||||
|
@ -857,8 +846,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
jsAst.Expression laziesAccess =
|
||||
generateEmbeddedGlobalAccess(embeddedNames.LAZIES);
|
||||
|
||||
return js.statement(
|
||||
'''
|
||||
return js.statement('''
|
||||
function init() {
|
||||
$isolatePropertiesName = Object.create(null);
|
||||
#allClasses = map();
|
||||
|
@ -962,22 +950,21 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
return Isolate;
|
||||
}
|
||||
|
||||
}''',
|
||||
{
|
||||
'allClasses': allClassesAccess,
|
||||
'getTypeFromName': getTypeFromNameAccess,
|
||||
'interceptorsByTag': interceptorsByTagAccess,
|
||||
'leafTags': leafTagsAccess,
|
||||
'finishedClasses': finishedClassesAccess,
|
||||
'needsLazyInitializer': needsLazyInitializer,
|
||||
'lazies': laziesAccess,
|
||||
'cyclicThrow': cyclicThrow,
|
||||
'isolatePropertiesName': namer.isolatePropertiesName,
|
||||
'outputContainsConstantList': outputContainsConstantList,
|
||||
'makeConstListProperty': makeConstListProperty,
|
||||
'functionThatReturnsNullProperty':
|
||||
backend.rtiEncoder.getFunctionThatReturnsNullName,
|
||||
});
|
||||
}''', {
|
||||
'allClasses': allClassesAccess,
|
||||
'getTypeFromName': getTypeFromNameAccess,
|
||||
'interceptorsByTag': interceptorsByTagAccess,
|
||||
'leafTags': leafTagsAccess,
|
||||
'finishedClasses': finishedClassesAccess,
|
||||
'needsLazyInitializer': needsLazyInitializer,
|
||||
'lazies': laziesAccess,
|
||||
'cyclicThrow': cyclicThrow,
|
||||
'isolatePropertiesName': namer.isolatePropertiesName,
|
||||
'outputContainsConstantList': outputContainsConstantList,
|
||||
'makeConstListProperty': makeConstListProperty,
|
||||
'functionThatReturnsNullProperty':
|
||||
backend.rtiEncoder.getFunctionThatReturnsNullName,
|
||||
});
|
||||
}
|
||||
|
||||
jsAst.Statement buildConvertToFastObjectFunction() {
|
||||
|
@ -996,8 +983,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
}'''));
|
||||
}
|
||||
|
||||
return js.statement(
|
||||
r'''
|
||||
return js.statement(r'''
|
||||
function convertToFastObject(properties) {
|
||||
// Create an instance that uses 'properties' as prototype. This should
|
||||
// make 'properties' a fast object.
|
||||
|
@ -1006,8 +992,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
new MyClass();
|
||||
#;
|
||||
return properties;
|
||||
}''',
|
||||
[debugCode]);
|
||||
}''', [debugCode]);
|
||||
}
|
||||
|
||||
jsAst.Statement buildConvertToSlowObjectFunction() {
|
||||
|
@ -1262,15 +1247,13 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
'''));
|
||||
|
||||
for (String object in Namer.userGlobalObjects) {
|
||||
parts.add(js.statement(
|
||||
'''
|
||||
parts.add(js.statement('''
|
||||
if (typeof print === "function") {
|
||||
print("Size of " + #objectString + ": "
|
||||
+ String(Object.getOwnPropertyNames(#object).length)
|
||||
+ ", fast properties " + HasFastProperties(#object));
|
||||
}
|
||||
''',
|
||||
{"object": object, "objectString": js.string(object)}));
|
||||
''', {"object": object, "objectString": js.string(object)}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1403,8 +1386,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
|
||||
// Using a named function here produces easier to read stack traces in
|
||||
// Chrome/V8.
|
||||
statements.add(js.statement(
|
||||
"""
|
||||
statements.add(js.statement("""
|
||||
(function() {
|
||||
// No renaming in the top-level function to save the locals for the
|
||||
// nested context where they will be used more. We have to put the
|
||||
|
@ -1501,48 +1483,44 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
|
||||
#main;
|
||||
})();
|
||||
""",
|
||||
{
|
||||
"disableVariableRenaming": js.comment("/* ::norenaming:: */"),
|
||||
"isProgramSplit": isProgramSplit,
|
||||
"supportsDirectProtoAccess": buildSupportsDirectProtoAccess(),
|
||||
"globalsHolder": globalsHolder,
|
||||
"globalObjectSetup": buildGlobalObjectSetup(isProgramSplit),
|
||||
"isolateName": namer.isolateName,
|
||||
"isolatePropertiesName": js(isolatePropertiesName),
|
||||
"initName": initName,
|
||||
"functionThatReturnsNull": buildFunctionThatReturnsNull(),
|
||||
"mangledNames": buildMangledNames(),
|
||||
"setupProgram": buildSetupProgram(
|
||||
program, compiler, backend, namer, this, _closedWorld),
|
||||
"setupProgramName": setupProgramName,
|
||||
"descriptors": descriptorsAst,
|
||||
"cspPrecompiledFunctions":
|
||||
buildCspPrecompiledFunctionFor(mainOutputUnit),
|
||||
"getInterceptorMethods":
|
||||
interceptorEmitter.buildGetInterceptorMethods(),
|
||||
"oneShotInterceptors": interceptorEmitter.buildOneShotInterceptors(),
|
||||
"makeConstantList":
|
||||
buildMakeConstantList(program.outputContainsConstantList),
|
||||
"compileTimeConstants": buildCompileTimeConstants(
|
||||
mainFragment.constants,
|
||||
isMainFragment: true),
|
||||
"deferredBoilerPlate": buildDeferredBoilerPlate(deferredLoadHashes),
|
||||
"staticNonFinalInitializers":
|
||||
buildStaticNonFinalFieldInitializations(mainOutputUnit),
|
||||
"typeToInterceptorMap":
|
||||
interceptorEmitter.buildTypeToInterceptorMap(program),
|
||||
"lazyStaticFields": buildLazilyInitializedStaticFields(
|
||||
mainFragment.staticLazilyInitializedFields),
|
||||
"metadata": buildMetadata(program, mainOutputUnit),
|
||||
"convertToFastObject": buildConvertToFastObjectFunction(),
|
||||
"convertToSlowObject": buildConvertToSlowObjectFunction(),
|
||||
"convertGlobalObjectsToFastObjects":
|
||||
buildConvertGlobalObjectToFastObjects(),
|
||||
"debugFastObjects": buildDebugFastObjectCode(),
|
||||
"init": buildInitFunction(program.outputContainsConstantList),
|
||||
"main": buildMain(mainFragment.invokeMain)
|
||||
}));
|
||||
""", {
|
||||
"disableVariableRenaming": js.comment("/* ::norenaming:: */"),
|
||||
"isProgramSplit": isProgramSplit,
|
||||
"supportsDirectProtoAccess": buildSupportsDirectProtoAccess(),
|
||||
"globalsHolder": globalsHolder,
|
||||
"globalObjectSetup": buildGlobalObjectSetup(isProgramSplit),
|
||||
"isolateName": namer.isolateName,
|
||||
"isolatePropertiesName": js(isolatePropertiesName),
|
||||
"initName": initName,
|
||||
"functionThatReturnsNull": buildFunctionThatReturnsNull(),
|
||||
"mangledNames": buildMangledNames(),
|
||||
"setupProgram": buildSetupProgram(
|
||||
program, compiler, backend, namer, this, _closedWorld),
|
||||
"setupProgramName": setupProgramName,
|
||||
"descriptors": descriptorsAst,
|
||||
"cspPrecompiledFunctions": buildCspPrecompiledFunctionFor(mainOutputUnit),
|
||||
"getInterceptorMethods": interceptorEmitter.buildGetInterceptorMethods(),
|
||||
"oneShotInterceptors": interceptorEmitter.buildOneShotInterceptors(),
|
||||
"makeConstantList":
|
||||
buildMakeConstantList(program.outputContainsConstantList),
|
||||
"compileTimeConstants": buildCompileTimeConstants(mainFragment.constants,
|
||||
isMainFragment: true),
|
||||
"deferredBoilerPlate": buildDeferredBoilerPlate(deferredLoadHashes),
|
||||
"staticNonFinalInitializers":
|
||||
buildStaticNonFinalFieldInitializations(mainOutputUnit),
|
||||
"typeToInterceptorMap":
|
||||
interceptorEmitter.buildTypeToInterceptorMap(program),
|
||||
"lazyStaticFields": buildLazilyInitializedStaticFields(
|
||||
mainFragment.staticLazilyInitializedFields),
|
||||
"metadata": buildMetadata(program, mainOutputUnit),
|
||||
"convertToFastObject": buildConvertToFastObjectFunction(),
|
||||
"convertToSlowObject": buildConvertToSlowObjectFunction(),
|
||||
"convertGlobalObjectsToFastObjects":
|
||||
buildConvertGlobalObjectToFastObjects(),
|
||||
"debugFastObjects": buildDebugFastObjectCode(),
|
||||
"init": buildInitFunction(program.outputContainsConstantList),
|
||||
"main": buildMain(mainFragment.invokeMain)
|
||||
}));
|
||||
|
||||
return new jsAst.Program(statements);
|
||||
}
|
||||
|
@ -1717,8 +1695,7 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
Map<OutputUnit, _DeferredOutputUnitHash> deferredLoadHashes) {
|
||||
List<jsAst.Statement> parts = <jsAst.Statement>[];
|
||||
|
||||
parts.add(js.statement(
|
||||
'''
|
||||
parts.add(js.statement('''
|
||||
{
|
||||
// Function for checking if a hunk is loaded given its hash.
|
||||
#isHunkLoaded = function(hunkHash) {
|
||||
|
@ -1736,18 +1713,17 @@ class Emitter extends js_emitter.EmitterBase {
|
|||
#deferredInitialized[hunkHash] = true;
|
||||
};
|
||||
}
|
||||
''',
|
||||
{
|
||||
"globalsHolder": globalsHolder,
|
||||
"isHunkLoaded":
|
||||
generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED),
|
||||
"isHunkInitialized":
|
||||
generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_INITIALIZED),
|
||||
"initializeLoadedHunk": generateEmbeddedGlobalAccess(
|
||||
embeddedNames.INITIALIZE_LOADED_HUNK),
|
||||
"deferredInitialized":
|
||||
generateEmbeddedGlobalAccess(embeddedNames.DEFERRED_INITIALIZED)
|
||||
}));
|
||||
''', {
|
||||
"globalsHolder": globalsHolder,
|
||||
"isHunkLoaded":
|
||||
generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED),
|
||||
"isHunkInitialized":
|
||||
generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_INITIALIZED),
|
||||
"initializeLoadedHunk":
|
||||
generateEmbeddedGlobalAccess(embeddedNames.INITIALIZE_LOADED_HUNK),
|
||||
"deferredInitialized":
|
||||
generateEmbeddedGlobalAccess(embeddedNames.DEFERRED_INITIALIZED)
|
||||
}));
|
||||
|
||||
// Write a javascript mapping from Deferred import load ids (derrived
|
||||
// from the import prefix.) to a list of lists of uris of hunks to load,
|
||||
|
|
|
@ -180,8 +180,7 @@ class NsmEmitter extends CodeEmitterHelper {
|
|||
.staticFunctionAccess(
|
||||
closedWorld.commonElements.createInvocationMirror);
|
||||
if (useDiffEncoding) {
|
||||
statements.add(js.statement(
|
||||
'''{
|
||||
statements.add(js.statement('''{
|
||||
var objectClassObject = processedClasses.collected[#objectClass],
|
||||
nameSequences = #diffEncoding.split("."),
|
||||
shortNames = [];
|
||||
|
@ -221,11 +220,10 @@ class NsmEmitter extends CodeEmitterHelper {
|
|||
Array.prototype.push.apply(shortNames, sequence.shift());
|
||||
}
|
||||
}
|
||||
}''',
|
||||
{
|
||||
'objectClass': js.quoteName(namer.className(objectClass)),
|
||||
'diffEncoding': sortedShorts
|
||||
}));
|
||||
}''', {
|
||||
'objectClass': js.quoteName(namer.className(objectClass)),
|
||||
'diffEncoding': sortedShorts
|
||||
}));
|
||||
} else {
|
||||
// No useDiffEncoding version.
|
||||
statements.add(js.statement(
|
||||
|
@ -250,8 +248,7 @@ class NsmEmitter extends CodeEmitterHelper {
|
|||
? true
|
||||
: js('j < #', js.number(interceptedSelectors.length));
|
||||
|
||||
statements.add(js.statement(
|
||||
'''
|
||||
statements.add(js.statement('''
|
||||
// If we are loading a deferred library the object class will not be in
|
||||
// the collectedClasses so objectClassObject is undefined, and we skip
|
||||
// setting up the names.
|
||||
|
@ -298,13 +295,12 @@ class NsmEmitter extends CodeEmitterHelper {
|
|||
})(#names[j], shortName, type);
|
||||
}
|
||||
}
|
||||
}''',
|
||||
{
|
||||
'noSuchMethodName': namer.noSuchMethodName,
|
||||
'createInvocationMirror': createInvocationMirror,
|
||||
'names': minify ? 'shortNames' : 'longNames',
|
||||
'isIntercepted': isIntercepted
|
||||
}));
|
||||
}''', {
|
||||
'noSuchMethodName': namer.noSuchMethodName,
|
||||
'createInvocationMirror': createInvocationMirror,
|
||||
'names': minify ? 'shortNames' : 'longNames',
|
||||
'isIntercepted': isIntercepted
|
||||
}));
|
||||
|
||||
return statements;
|
||||
}
|
||||
|
|
|
@ -153,8 +153,7 @@ class InterceptorStubGenerator {
|
|||
: _commonElements.jsNumberClass);
|
||||
|
||||
if (hasInt) {
|
||||
whenNumber = js.statement(
|
||||
'''{
|
||||
whenNumber = js.statement('''{
|
||||
if (Math.floor(receiver) == receiver) return #;
|
||||
return #;
|
||||
}''',
|
||||
|
@ -187,21 +186,19 @@ class InterceptorStubGenerator {
|
|||
}
|
||||
|
||||
if (hasNative) {
|
||||
statements.add(js.statement(
|
||||
r'''{
|
||||
statements.add(js.statement(r'''{
|
||||
if (typeof receiver != "object") {
|
||||
if (typeof receiver == "function" ) return #;
|
||||
return receiver;
|
||||
}
|
||||
if (receiver instanceof #) return receiver;
|
||||
return #(receiver);
|
||||
}''',
|
||||
[
|
||||
interceptorFor(_commonElements.jsJavaScriptFunctionClass),
|
||||
_emitter.constructorAccess(_commonElements.objectClass),
|
||||
_emitter.staticFunctionAccess(
|
||||
_commonElements.getNativeInterceptorMethod)
|
||||
]));
|
||||
}''', [
|
||||
interceptorFor(_commonElements.jsJavaScriptFunctionClass),
|
||||
_emitter.constructorAccess(_commonElements.objectClass),
|
||||
_emitter
|
||||
.staticFunctionAccess(_commonElements.getNativeInterceptorMethod)
|
||||
]));
|
||||
} else {
|
||||
ClassEntity jsUnknown = _commonElements.jsUnknownJavaScriptObjectClass;
|
||||
if (_codegenWorldBuilder.directlyInstantiatedClasses
|
||||
|
@ -339,14 +336,12 @@ class InterceptorStubGenerator {
|
|||
typeCheck = orExp(typeCheck, indexableCheck);
|
||||
}
|
||||
|
||||
return js.statement(
|
||||
'''
|
||||
return js.statement('''
|
||||
if (typeof a0 === "number")
|
||||
if (#)
|
||||
if ((a0 >>> 0) === a0 && a0 < receiver.length)
|
||||
return receiver[a0];
|
||||
''',
|
||||
typeCheck);
|
||||
''', typeCheck);
|
||||
} else {
|
||||
jsAst.Expression typeCheck;
|
||||
if (containsArray) {
|
||||
|
@ -357,14 +352,12 @@ class InterceptorStubGenerator {
|
|||
typeCheck = orExp(typeCheck, indexableCheck);
|
||||
}
|
||||
|
||||
return js.statement(
|
||||
r'''
|
||||
return js.statement(r'''
|
||||
if (typeof a0 === "number")
|
||||
if (# && !receiver.immutable$list &&
|
||||
(a0 >>> 0) === a0 && a0 < receiver.length)
|
||||
return receiver[a0] = a1;
|
||||
''',
|
||||
typeCheck);
|
||||
''', typeCheck);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -438,16 +438,14 @@ class ModelEmitter {
|
|||
|
||||
/// See [emitEmbeddedGlobalsForDeferredLoading] for the format of the
|
||||
/// deferred hunk.
|
||||
js.Expression initializeLoadedHunkFunction = js.js(
|
||||
"""
|
||||
js.Expression initializeLoadedHunkFunction = js.js("""
|
||||
function(hash) {
|
||||
var hunk = $deferredInitializersGlobal[hash];
|
||||
$setupProgramName(hunk[0], #typesAccess.length);
|
||||
eval(hunk[1]);
|
||||
var deferredTypes = eval(hunk[2]);
|
||||
#typesAccess.push.apply(#typesAccess, deferredTypes);
|
||||
}""",
|
||||
{'typesAccess': typesAccess});
|
||||
}""", {'typesAccess': typesAccess});
|
||||
|
||||
globals.add(new js.Property(
|
||||
js.string(INITIALIZE_LOADED_HUNK), initializeLoadedHunkFunction));
|
||||
|
@ -468,16 +466,14 @@ class ModelEmitter {
|
|||
// Types are non-evaluated and must be compiled at first use.
|
||||
// Compiled strings are guaranteed not to be strings, and it's thus safe
|
||||
// to use a type-test to determine if a type has already been compiled.
|
||||
return js.js.statement(
|
||||
'''function $readMetadataTypeName(index) {
|
||||
return js.js.statement('''function $readMetadataTypeName(index) {
|
||||
var type = #typesAccess[index];
|
||||
if (typeof type == 'string') {
|
||||
type = expressionCompile(type);
|
||||
#typesAccess[index] = type;
|
||||
}
|
||||
return type;
|
||||
}''',
|
||||
{"typesAccess": generateEmbeddedGlobalAccess(TYPES)});
|
||||
}''', {"typesAccess": generateEmbeddedGlobalAccess(TYPES)});
|
||||
}
|
||||
|
||||
js.Template get templateForReadType {
|
||||
|
@ -493,19 +489,17 @@ class ModelEmitter {
|
|||
// Types are non-evaluated and must be compiled at first use.
|
||||
// Compiled strings are guaranteed not to be strings, and it's thus safe
|
||||
// to use a type-test to determine if a type has already been compiled.
|
||||
return js.js.statement(
|
||||
'''function $readMetadataName(index) {
|
||||
return js.js.statement('''function $readMetadataName(index) {
|
||||
var lazyMetadata = #lazyMetadataAccess[index];
|
||||
if (typeof lazyMetadata == 'string') {
|
||||
#metadataAccess[index] = expressionCompile(lazyMetadata);
|
||||
#lazyMetadataAccess[index] = null;
|
||||
}
|
||||
return #metadataAccess[index];
|
||||
}''',
|
||||
{
|
||||
"lazyMetadataAccess": generateEmbeddedGlobalAccess(lazyMetadataName),
|
||||
"metadataAccess": generateEmbeddedGlobalAccess(METADATA)
|
||||
});
|
||||
}''', {
|
||||
"lazyMetadataAccess": generateEmbeddedGlobalAccess(lazyMetadataName),
|
||||
"metadataAccess": generateEmbeddedGlobalAccess(METADATA)
|
||||
});
|
||||
}
|
||||
|
||||
js.Template get templateForReadMetadata {
|
||||
|
|
|
@ -49,8 +49,7 @@ class MainCallStubGenerator {
|
|||
// onload event of all script tags and getting the first script which
|
||||
// finishes. Since onload is called immediately after execution this should
|
||||
// not substantially change execution order.
|
||||
return js.statement(
|
||||
'''
|
||||
return js.statement('''
|
||||
(function (callback) {
|
||||
if (typeof document === "undefined") {
|
||||
callback(null);
|
||||
|
@ -81,10 +80,9 @@ class MainCallStubGenerator {
|
|||
} else {
|
||||
#mainCallClosure([]);
|
||||
}
|
||||
})''',
|
||||
{
|
||||
'currentScript': currentScriptAccess,
|
||||
'mainCallClosure': mainCallClosure
|
||||
});
|
||||
})''', {
|
||||
'currentScript': currentScriptAccess,
|
||||
'mainCallClosure': mainCallClosure
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ class NativeGenerator {
|
|||
jsAst.Expression dispatchPropertyNameAccess =
|
||||
generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME);
|
||||
|
||||
return js.statement(
|
||||
'''
|
||||
return js.statement('''
|
||||
!function() {
|
||||
var intern = #internStringFunction;
|
||||
|
||||
|
@ -63,15 +62,14 @@ class NativeGenerator {
|
|||
#dispatchPropertyName = #getIsolateTag("dispatch_record");
|
||||
}
|
||||
}();
|
||||
''',
|
||||
{
|
||||
'initializeDispatchProperty':
|
||||
backendUsage.needToInitializeDispatchProperty,
|
||||
'internStringFunction': internStringFunction,
|
||||
'getIsolateTag': getIsolateTagAccess,
|
||||
'isolateTag': isolateTagAccess,
|
||||
'dispatchPropertyName': dispatchPropertyNameAccess
|
||||
});
|
||||
''', {
|
||||
'initializeDispatchProperty':
|
||||
backendUsage.needToInitializeDispatchProperty,
|
||||
'internStringFunction': internStringFunction,
|
||||
'getIsolateTag': getIsolateTagAccess,
|
||||
'isolateTag': isolateTagAccess,
|
||||
'dispatchPropertyName': dispatchPropertyNameAccess
|
||||
});
|
||||
}
|
||||
|
||||
static String generateIsolateTagRoot() {
|
||||
|
@ -155,8 +153,7 @@ class NativeGenerator {
|
|||
jsAst.Expression leafTagsAccess) {
|
||||
jsAst.Expression subclassRead =
|
||||
subclassReadGenerator(js('subclasses[i]', []));
|
||||
return js.statement(
|
||||
'''
|
||||
return js.statement('''
|
||||
// The native info looks like this:
|
||||
//
|
||||
// HtmlElement: {
|
||||
|
@ -204,15 +201,14 @@ class NativeGenerator {
|
|||
}
|
||||
}
|
||||
}
|
||||
''',
|
||||
{
|
||||
'info': infoAccess,
|
||||
'constructor': constructorAccess,
|
||||
'subclassRead': subclassRead,
|
||||
'interceptorsByTagAccess': interceptorsByTagAccess,
|
||||
'leafTagsAccess': leafTagsAccess,
|
||||
'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME,
|
||||
'allowNativesSubclassing': true
|
||||
});
|
||||
''', {
|
||||
'info': infoAccess,
|
||||
'constructor': constructorAccess,
|
||||
'subclassRead': subclassRead,
|
||||
'interceptorsByTagAccess': interceptorsByTagAccess,
|
||||
'leafTagsAccess': leafTagsAccess,
|
||||
'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME,
|
||||
'allowNativesSubclassing': true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1121,23 +1121,21 @@ class FragmentEmitter {
|
|||
_encodeOptionalParameterDefaultValues(method);
|
||||
}
|
||||
|
||||
return js.js.statement(
|
||||
'''
|
||||
return js.js.statement('''
|
||||
installTearOff(#container, #getterName, #isStatic, #isIntercepted,
|
||||
#requiredParameterCount, #optionalParameterDefaultValues,
|
||||
#callNames, #funsOrNames, #funType)''',
|
||||
{
|
||||
"container": container,
|
||||
"getterName": js.quoteName(method.tearOffName),
|
||||
// 'Truthy' values are ok for `isStatic` and `isIntercepted`.
|
||||
"isStatic": js.number(method.isStatic ? 1 : 0),
|
||||
"isIntercepted": js.number(isIntercepted ? 1 : 0),
|
||||
"requiredParameterCount": js.number(requiredParameterCount),
|
||||
"optionalParameterDefaultValues": optionalParameterDefaultValues,
|
||||
"callNames": callNameArray,
|
||||
"funsOrNames": funsOrNamesArray,
|
||||
"funType": method.functionType,
|
||||
});
|
||||
#callNames, #funsOrNames, #funType)''', {
|
||||
"container": container,
|
||||
"getterName": js.quoteName(method.tearOffName),
|
||||
// 'Truthy' values are ok for `isStatic` and `isIntercepted`.
|
||||
"isStatic": js.number(method.isStatic ? 1 : 0),
|
||||
"isIntercepted": js.number(isIntercepted ? 1 : 0),
|
||||
"requiredParameterCount": js.number(requiredParameterCount),
|
||||
"optionalParameterDefaultValues": optionalParameterDefaultValues,
|
||||
"callNames": callNameArray,
|
||||
"funsOrNames": funsOrNamesArray,
|
||||
"funType": method.functionType,
|
||||
});
|
||||
}
|
||||
|
||||
/// Wraps the statement in a named function to that it shows up as a unit in
|
||||
|
@ -1303,16 +1301,13 @@ class FragmentEmitter {
|
|||
|
||||
/// See [emitEmbeddedGlobalsForDeferredLoading] for the format of the
|
||||
/// deferred hunk.
|
||||
js.Expression initializeLoadedHunkFunction = js.js(
|
||||
"""
|
||||
js.Expression initializeLoadedHunkFunction = js.js("""
|
||||
function(hash) {
|
||||
initializeDeferredHunk($deferredGlobal[hash]);
|
||||
#deferredInitialized[hash] = true;
|
||||
}""",
|
||||
{
|
||||
'deferredInitialized':
|
||||
generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED)
|
||||
});
|
||||
}""", {
|
||||
'deferredInitialized': generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED)
|
||||
});
|
||||
|
||||
globals.add(new js.Property(
|
||||
js.string(INITIALIZE_LOADED_HUNK), initializeLoadedHunkFunction));
|
||||
|
@ -1505,18 +1500,14 @@ class FragmentEmitter {
|
|||
NativeGenerator
|
||||
.needsIsolateAffinityTagInitialization(_closedWorld.backendUsage)) {
|
||||
statements.add(NativeGenerator.generateIsolateAffinityTagInitialization(
|
||||
_closedWorld.backendUsage,
|
||||
generateEmbeddedGlobalAccess,
|
||||
js.js(
|
||||
"""
|
||||
_closedWorld.backendUsage, generateEmbeddedGlobalAccess, js.js("""
|
||||
// On V8, the 'intern' function converts a string to a symbol, which
|
||||
// makes property access much faster.
|
||||
function (s) {
|
||||
var o = {};
|
||||
o[s] = 1;
|
||||
return Object.keys(convertToFastObject(o))[0];
|
||||
}""",
|
||||
[])));
|
||||
}""", [])));
|
||||
}
|
||||
|
||||
Map<String, js.Expression> interceptorsByTag = <String, js.Expression>{};
|
||||
|
|
|
@ -113,22 +113,18 @@ main() {
|
|||
Expect.equals("${template.message({'main': 'main'})}", warnings.single);
|
||||
});
|
||||
|
||||
runCompiler(
|
||||
"""main() {
|
||||
runCompiler("""main() {
|
||||
Foo foo; // Unresolved and analyzed.
|
||||
}""",
|
||||
[Flags.analyzeOnly], (String code, List errors, List warnings) {
|
||||
}""", [Flags.analyzeOnly], (String code, List errors, List warnings) {
|
||||
Expect.isNull(code);
|
||||
Expect.isTrue(errors.isEmpty);
|
||||
Expect.equals(1, warnings.length);
|
||||
Expect.equals("Cannot resolve type 'Foo'.", warnings[0].toString());
|
||||
});
|
||||
|
||||
runCompiler(
|
||||
"""main() {
|
||||
runCompiler("""main() {
|
||||
Foo foo; // Unresolved and analyzed.
|
||||
}""",
|
||||
[Flags.analyzeOnly, Flags.analyzeSignaturesOnly],
|
||||
}""", [Flags.analyzeOnly, Flags.analyzeSignaturesOnly],
|
||||
(String code, List errors, List warnings) {
|
||||
Expect.isNull(code);
|
||||
Expect.isTrue(errors.isEmpty);
|
||||
|
@ -144,10 +140,8 @@ main() {
|
|||
Expect.equals("Cannot resolve type 'Foo'.", warnings[0].toString());
|
||||
});
|
||||
|
||||
runCompiler(
|
||||
"""Foo foo; // Unresolved and analyzed.
|
||||
main() {}""",
|
||||
[Flags.analyzeOnly, Flags.analyzeAll],
|
||||
runCompiler("""Foo foo; // Unresolved and analyzed.
|
||||
main() {}""", [Flags.analyzeOnly, Flags.analyzeAll],
|
||||
(String code, List errors, List warnings) {
|
||||
Expect.isNull(code);
|
||||
Expect.isTrue(errors.isEmpty, 'Unexpected errors: $errors.');
|
||||
|
@ -171,19 +165,16 @@ main() {
|
|||
});
|
||||
|
||||
// Test that --allow-native-extensions works.
|
||||
runCompiler(
|
||||
"""main() {}
|
||||
foo() native 'foo';""",
|
||||
[Flags.analyzeOnly, Flags.allowNativeExtensions],
|
||||
runCompiler("""main() {}
|
||||
foo() native 'foo';""", [Flags.analyzeOnly, Flags.allowNativeExtensions],
|
||||
(String code, List errors, List warnings) {
|
||||
Expect.isNull(code);
|
||||
Expect.isTrue(errors.isEmpty);
|
||||
Expect.isTrue(warnings.isEmpty);
|
||||
});
|
||||
runCompiler(
|
||||
"""main() {}
|
||||
foo() native 'foo';""",
|
||||
[Flags.analyzeOnly], (String code, List errors, List warnings) {
|
||||
runCompiler("""main() {}
|
||||
foo() native 'foo';""", [Flags.analyzeOnly],
|
||||
(String code, List errors, List warnings) {
|
||||
Expect.isNull(code);
|
||||
Expect.isTrue(
|
||||
errors.single.startsWith("'native' modifier is not supported."));
|
||||
|
|
|
@ -94,13 +94,11 @@ main() {
|
|||
/// 01: ok
|
||||
;
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(a) async {
|
||||
print(this.x); // Ensure `this` is translated in the helper function.
|
||||
await foo();
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(a) {
|
||||
var __goto = 0, __completer = NewCompleter(), __self = this;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -122,8 +120,7 @@ function(a) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(b) async {
|
||||
try {
|
||||
__outer: while (true) { // Overlapping label name.
|
||||
|
@ -146,8 +143,7 @@ function(a) {
|
|||
return 3; // Return from finally with no pending finally.
|
||||
}
|
||||
return 4;
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(b) {
|
||||
var __goto = 0, __completer = NewCompleter(), __returnValue, __handler = 2, __currentError, __next = [], __helper;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -248,8 +244,7 @@ function(b) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(c) async {
|
||||
var a, b, c, d, e, f;
|
||||
a = b++; // post- and preincrements.
|
||||
|
@ -258,8 +253,7 @@ function(c) async {
|
|||
d = ++(await foo()).a;
|
||||
e = foo1()[await foo2()]--;
|
||||
f = --foo1()[await foo2()];
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(c) {
|
||||
var __goto = 0, __completer = NewCompleter(), a, b, c, d, e, f, __temp1;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -300,8 +294,7 @@ function(c) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(d2) async {
|
||||
var a, b, c, d, e, f, g, h; // empty initializer
|
||||
a = foo1() || await foo2(); // short circuiting operators
|
||||
|
@ -312,8 +305,7 @@ function(c) {
|
|||
f = await foo1() && foo2();
|
||||
g = await foo1() && await foo2();
|
||||
h = foo1() && foo2();
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(d2) {
|
||||
var __goto = 0, __completer = NewCompleter(), a, b, c, d, e, f, g, h, __temp1;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -430,8 +422,7 @@ function(d2) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(x, y) async {
|
||||
while (true) {
|
||||
switch(y) { // Switch with no awaits in case key expressions
|
||||
|
@ -446,8 +437,7 @@ function(x, y) async {
|
|||
foo(); // No default
|
||||
}
|
||||
}
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(x, y) {
|
||||
var __goto = 0, __completer = NewCompleter();
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -521,8 +511,7 @@ function(x, y) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(f) async {
|
||||
do {
|
||||
var a = await foo();
|
||||
|
@ -532,8 +521,7 @@ function(x, y) {
|
|||
continue;
|
||||
} while (await foo());
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
function(f) {
|
||||
var __goto = 0, __completer = NewCompleter(), a;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -579,8 +567,7 @@ function(f) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(g) async {
|
||||
for (var i = 0; i < await foo1(); i += await foo2()) {
|
||||
if (foo(i))
|
||||
|
@ -594,8 +581,7 @@ function(g) async {
|
|||
print(await(foo(i)));
|
||||
}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
function(g) {
|
||||
var __goto = 0, __completer = NewCompleter(), __returnValue, i, __temp1;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -666,8 +652,7 @@ function(g) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(a, h) async {
|
||||
var x = {"a": foo1(), "b": await foo2(), "c": foo3()};
|
||||
x["a"] = 2; // Different assignments
|
||||
|
@ -676,8 +661,7 @@ function(g) {
|
|||
x[(await foo1()).a = await foo2()] = 5;
|
||||
(await foo1())[await foo2()] = await foo3(6);
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
function(a, h) {
|
||||
var __goto = 0, __completer = NewCompleter(), x, __temp1, __temp2;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -738,8 +722,7 @@ function(a, h) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(c, i) async {
|
||||
try {
|
||||
var x = c ? await foo() : foo(); // conditional
|
||||
|
@ -754,8 +737,7 @@ function(c, i) async {
|
|||
}
|
||||
}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
function(c, i) {
|
||||
var __goto = 0, __completer = NewCompleter(), __handler = 1, __currentError, __next = [], x, y, __error, __error1;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -857,8 +839,7 @@ function(c, i) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(x, y, j) async {
|
||||
print(await(foo(x))); // calls
|
||||
(await print)(foo(x));
|
||||
|
@ -866,8 +847,7 @@ function(c, i) {
|
|||
await (print(foo(await x)));
|
||||
print(foo(x, await y, z));
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
function(x, y, j) {
|
||||
var __goto = 0, __completer = NewCompleter(), __temp1, __temp2, __temp3;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -920,8 +900,7 @@ function(x, y, j) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(x, y, k) async {
|
||||
while (await(foo())) {
|
||||
lab: { // labelled statement
|
||||
|
@ -946,8 +925,7 @@ function(x, y, k) async {
|
|||
foo();
|
||||
}
|
||||
}
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(x, y, k) {
|
||||
var __goto = 0, __completer = NewCompleter(), __returnValue, __temp1;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -1057,8 +1035,7 @@ function(x, y, k) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(l) async {
|
||||
switch(await l) {
|
||||
case 1:
|
||||
|
@ -1071,8 +1048,7 @@ function(x, y, k) {
|
|||
print(2);
|
||||
break;
|
||||
}
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(l) {
|
||||
var __goto = 0, __completer = NewCompleter();
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -1103,8 +1079,7 @@ function(l) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testAsyncTransform(
|
||||
"""
|
||||
testAsyncTransform("""
|
||||
function(m) async {
|
||||
var exception = 1;
|
||||
try {
|
||||
|
@ -1120,8 +1095,7 @@ function(l) {
|
|||
exception += 10;
|
||||
}
|
||||
print(exception);
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(m) {
|
||||
var __goto = 0, __completer = NewCompleter(), __handler = 1, __currentError, __next = [], exception, __exception;
|
||||
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
|
||||
|
@ -1184,14 +1158,12 @@ function(m) {
|
|||
return startHelper(body, __completer);
|
||||
}""");
|
||||
|
||||
testSyncStarTransform(
|
||||
"""
|
||||
testSyncStarTransform("""
|
||||
function(a) sync* {
|
||||
// Ensure that return of a value is treated as first evaluating the value, and
|
||||
// then returning.
|
||||
return foo();
|
||||
}""",
|
||||
"""
|
||||
}""", """
|
||||
function(__a) {
|
||||
return NewIterable(function() {
|
||||
var a = __a;
|
||||
|
|
|
@ -23,8 +23,7 @@ void main() {
|
|||
}
|
||||
|
||||
testIterators() async {
|
||||
var env = await TypeEnvironment.create(
|
||||
r"""
|
||||
var env = await TypeEnvironment.create(r"""
|
||||
/// A
|
||||
/// / \
|
||||
/// B C
|
||||
|
@ -38,8 +37,7 @@ testIterators() async {
|
|||
class E extends C {}
|
||||
class F extends C {}
|
||||
class G extends C {}
|
||||
""",
|
||||
mainSource: r"""
|
||||
""", mainSource: r"""
|
||||
main() {
|
||||
new A();
|
||||
new C();
|
||||
|
@ -48,8 +46,7 @@ testIterators() async {
|
|||
new F();
|
||||
new G();
|
||||
}
|
||||
""",
|
||||
useMockCompiler: false);
|
||||
""", useMockCompiler: false);
|
||||
ClosedWorld world = env.closedWorld;
|
||||
|
||||
ClassElement A = env.getElement("A");
|
||||
|
@ -349,8 +346,7 @@ testIterators() async {
|
|||
}
|
||||
|
||||
testForEach() async {
|
||||
var env = await TypeEnvironment.create(
|
||||
r"""
|
||||
var env = await TypeEnvironment.create(r"""
|
||||
/// A
|
||||
/// / \
|
||||
/// B C
|
||||
|
@ -369,8 +365,7 @@ testForEach() async {
|
|||
class H extends F {}
|
||||
class I extends F {}
|
||||
class X {}
|
||||
""",
|
||||
mainSource: r"""
|
||||
""", mainSource: r"""
|
||||
main() {
|
||||
new A();
|
||||
new C();
|
||||
|
@ -381,8 +376,7 @@ testForEach() async {
|
|||
new H();
|
||||
new I();
|
||||
}
|
||||
""",
|
||||
useMockCompiler: false);
|
||||
""", useMockCompiler: false);
|
||||
ClosedWorld world = env.closedWorld;
|
||||
|
||||
ClassElement A = env.getElement("A");
|
||||
|
|
|
@ -307,5 +307,4 @@ checkerForAbsentPresent(String test) {
|
|||
|
||||
RegExp _directivePattern = new RegExp(
|
||||
// \1 \2 \3
|
||||
r'''// *(present|absent): *(?:"([^"]*)"|'([^'']*)')''',
|
||||
multiLine: true);
|
||||
r'''// *(present|absent): *(?:"([^"]*)"|'([^'']*)')''', multiLine: true);
|
||||
|
|
|
@ -11,9 +11,7 @@ test(String constantInitializer, [String expectedOutput]) {
|
|||
if (expectedOutput == null) {
|
||||
expectedOutput = constantInitializer;
|
||||
}
|
||||
return () => TypeEnvironment
|
||||
.create(
|
||||
"""
|
||||
return () => TypeEnvironment.create("""
|
||||
class Class<T, S> {
|
||||
final a;
|
||||
final b;
|
||||
|
@ -29,9 +27,7 @@ test(String constantInitializer, [String expectedOutput]) {
|
|||
const toplevelConstant = 0;
|
||||
toplevelFunction() {}
|
||||
const constant = $constantInitializer;
|
||||
""",
|
||||
expectNoWarningsOrErrors: true)
|
||||
.then((env) {
|
||||
""", expectNoWarningsOrErrors: true).then((env) {
|
||||
dynamic element = env.getElement('constant');
|
||||
Expect.isNotNull(element, "Element 'constant' not found.");
|
||||
var constant = element.constant;
|
||||
|
|
|
@ -128,8 +128,7 @@ const List<TestData> DATA = const [
|
|||
const {'foo': 'foo'}: 'StringConstant("foo")'
|
||||
}),
|
||||
]),
|
||||
const TestData(
|
||||
'''
|
||||
const TestData('''
|
||||
const a = const bool.fromEnvironment("foo", defaultValue: true);
|
||||
const b = const int.fromEnvironment("bar", defaultValue: 42);
|
||||
|
||||
|
@ -149,52 +148,50 @@ class D extends C {
|
|||
final field3 = 99;
|
||||
const D(a, b) : super(field2: a, field1: b);
|
||||
}
|
||||
''',
|
||||
const [
|
||||
const ConstantData('const Object()',
|
||||
const {const {}: 'ConstructedConstant(Object())'}),
|
||||
const ConstantData(
|
||||
'const A()', const {const {}: 'ConstructedConstant(A())'}),
|
||||
const ConstantData('const B(0)',
|
||||
const {const {}: 'ConstructedConstant(B(field1=IntConstant(0)))'}),
|
||||
const ConstantData('const B(const A())', const {
|
||||
const {}: 'ConstructedConstant(B(field1=ConstructedConstant(A())))'
|
||||
}),
|
||||
const ConstantData('const C()', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(42),'
|
||||
'field2=BoolConstant(false)))'
|
||||
}),
|
||||
const ConstantData('const C(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(87),'
|
||||
'field2=BoolConstant(false)))'
|
||||
}),
|
||||
const ConstantData('const C(field2: true)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(42),'
|
||||
'field2=BoolConstant(true)))'
|
||||
}),
|
||||
const ConstantData('const C.named()', const {
|
||||
const {}: 'ConstructedConstant(C(field1=BoolConstant(false),'
|
||||
'field2=BoolConstant(false)))'
|
||||
}),
|
||||
const ConstantData('const C.named(87)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(87),'
|
||||
'field2=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const C(field1: a, field2: b)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=BoolConstant(true),'
|
||||
'field2=IntConstant(42)))',
|
||||
const {'foo': 'false', 'bar': '87'}:
|
||||
'ConstructedConstant(C(field1=BoolConstant(false),'
|
||||
'field2=IntConstant(87)))',
|
||||
}),
|
||||
const ConstantData('const D(42, 87)', const {
|
||||
const {}: 'ConstructedConstant(D(field1=IntConstant(87),'
|
||||
'field2=IntConstant(42),'
|
||||
'field3=IntConstant(99)))'
|
||||
}),
|
||||
]),
|
||||
const TestData(
|
||||
'''
|
||||
''', const [
|
||||
const ConstantData(
|
||||
'const Object()', const {const {}: 'ConstructedConstant(Object())'}),
|
||||
const ConstantData(
|
||||
'const A()', const {const {}: 'ConstructedConstant(A())'}),
|
||||
const ConstantData('const B(0)',
|
||||
const {const {}: 'ConstructedConstant(B(field1=IntConstant(0)))'}),
|
||||
const ConstantData('const B(const A())', const {
|
||||
const {}: 'ConstructedConstant(B(field1=ConstructedConstant(A())))'
|
||||
}),
|
||||
const ConstantData('const C()', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(42),'
|
||||
'field2=BoolConstant(false)))'
|
||||
}),
|
||||
const ConstantData('const C(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(87),'
|
||||
'field2=BoolConstant(false)))'
|
||||
}),
|
||||
const ConstantData('const C(field2: true)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(42),'
|
||||
'field2=BoolConstant(true)))'
|
||||
}),
|
||||
const ConstantData('const C.named()', const {
|
||||
const {}: 'ConstructedConstant(C(field1=BoolConstant(false),'
|
||||
'field2=BoolConstant(false)))'
|
||||
}),
|
||||
const ConstantData('const C.named(87)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=IntConstant(87),'
|
||||
'field2=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const C(field1: a, field2: b)', const {
|
||||
const {}: 'ConstructedConstant(C(field1=BoolConstant(true),'
|
||||
'field2=IntConstant(42)))',
|
||||
const {'foo': 'false', 'bar': '87'}:
|
||||
'ConstructedConstant(C(field1=BoolConstant(false),'
|
||||
'field2=IntConstant(87)))',
|
||||
}),
|
||||
const ConstantData('const D(42, 87)', const {
|
||||
const {}: 'ConstructedConstant(D(field1=IntConstant(87),'
|
||||
'field2=IntConstant(42),'
|
||||
'field3=IntConstant(99)))'
|
||||
}),
|
||||
]),
|
||||
const TestData('''
|
||||
class A<T> implements B {
|
||||
final field1;
|
||||
const A({this.field1:42});
|
||||
|
@ -206,32 +203,30 @@ class B<S> implements C {
|
|||
class C<U> {
|
||||
const factory C({field1}) = A<B<double>>;
|
||||
}
|
||||
''',
|
||||
const [
|
||||
const ConstantData('const A()', const {
|
||||
const {}: 'ConstructedConstant(A<dynamic>(field1=IntConstant(42)))'
|
||||
}),
|
||||
const ConstantData('const A<int>(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(A<int>(field1=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const B()', const {
|
||||
const {}: 'ConstructedConstant(A<B<dynamic>>(field1=IntConstant(42)))'
|
||||
}),
|
||||
const ConstantData('const B<int>()', const {
|
||||
const {}: 'ConstructedConstant(A<B<int>>(field1=IntConstant(42)))'
|
||||
}),
|
||||
const ConstantData('const B<int>(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(A<B<int>>(field1=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const C<int>(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(A<B<double>>(field1=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const B<int>.named()', const {
|
||||
const {}: 'ConstructedConstant(A<int>(field1=IntConstant(42)))'
|
||||
}),
|
||||
]),
|
||||
const TestData(
|
||||
'''
|
||||
''', const [
|
||||
const ConstantData('const A()', const {
|
||||
const {}: 'ConstructedConstant(A<dynamic>(field1=IntConstant(42)))'
|
||||
}),
|
||||
const ConstantData('const A<int>(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(A<int>(field1=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const B()', const {
|
||||
const {}: 'ConstructedConstant(A<B<dynamic>>(field1=IntConstant(42)))'
|
||||
}),
|
||||
const ConstantData('const B<int>()', const {
|
||||
const {}: 'ConstructedConstant(A<B<int>>(field1=IntConstant(42)))'
|
||||
}),
|
||||
const ConstantData('const B<int>(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(A<B<int>>(field1=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const C<int>(field1: 87)', const {
|
||||
const {}: 'ConstructedConstant(A<B<double>>(field1=IntConstant(87)))'
|
||||
}),
|
||||
const ConstantData('const B<int>.named()', const {
|
||||
const {}: 'ConstructedConstant(A<int>(field1=IntConstant(42)))'
|
||||
}),
|
||||
]),
|
||||
const TestData('''
|
||||
const c = const int.fromEnvironment("foo", defaultValue: 5);
|
||||
const d = const int.fromEnvironment("bar", defaultValue: 10);
|
||||
|
||||
|
@ -243,18 +238,17 @@ class A {
|
|||
class B extends A {
|
||||
const B(a) : super(a, a * 2);
|
||||
}
|
||||
''',
|
||||
const [
|
||||
const ConstantData('const A(c, d)', const {
|
||||
const {}: 'ConstructedConstant(A(field=IntConstant(15)))',
|
||||
const {'foo': '7', 'bar': '11'}:
|
||||
'ConstructedConstant(A(field=IntConstant(18)))',
|
||||
}),
|
||||
const ConstantData('const B(d)', const {
|
||||
const {}: 'ConstructedConstant(B(field=IntConstant(30)))',
|
||||
const {'bar': '42'}: 'ConstructedConstant(B(field=IntConstant(126)))',
|
||||
}),
|
||||
]),
|
||||
''', const [
|
||||
const ConstantData('const A(c, d)', const {
|
||||
const {}: 'ConstructedConstant(A(field=IntConstant(15)))',
|
||||
const {'foo': '7', 'bar': '11'}:
|
||||
'ConstructedConstant(A(field=IntConstant(18)))',
|
||||
}),
|
||||
const ConstantData('const B(d)', const {
|
||||
const {}: 'ConstructedConstant(B(field=IntConstant(30)))',
|
||||
const {'bar': '42'}: 'ConstructedConstant(B(field=IntConstant(126)))',
|
||||
}),
|
||||
]),
|
||||
];
|
||||
|
||||
main() {
|
||||
|
|
|
@ -80,8 +80,7 @@ const List<TestData> DATA = const [
|
|||
'const String.fromEnvironment("foo", defaultValue: "bar")',
|
||||
ConstantExpressionKind.STRING_FROM_ENVIRONMENT),
|
||||
]),
|
||||
const TestData(
|
||||
'''
|
||||
const TestData('''
|
||||
class A {
|
||||
const A();
|
||||
}
|
||||
|
@ -94,54 +93,49 @@ class C extends B {
|
|||
const C({field1: 42, this.field2: false}) : super(field1);
|
||||
const C.named([field = false]) : this(field1: field, field2: field);
|
||||
}
|
||||
''',
|
||||
const [
|
||||
const ConstantData('const Object()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'Object', fields: const {}),
|
||||
const ConstantData('const A()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A', fields: const {}),
|
||||
const ConstantData('const B(0)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'B', fields: const {'field(B#field1)': '0'}),
|
||||
const ConstantData(
|
||||
'const B(const A())', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'B', fields: const {'field(B#field1)': 'const A()'}),
|
||||
const ConstantData('const C()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '42',
|
||||
'field(C#field2)': 'false',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '87',
|
||||
'field(C#field2)': 'false',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C(field2: true)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '42',
|
||||
'field(C#field2)': 'true',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C.named()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': 'false',
|
||||
'field(C#field2)': 'false',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C.named(87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '87',
|
||||
'field(C#field2)': '87',
|
||||
}),
|
||||
]),
|
||||
const TestData(
|
||||
'''
|
||||
''', const [
|
||||
const ConstantData('const Object()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'Object', fields: const {}),
|
||||
const ConstantData('const A()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A', fields: const {}),
|
||||
const ConstantData('const B(0)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'B', fields: const {'field(B#field1)': '0'}),
|
||||
const ConstantData('const B(const A())', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'B', fields: const {'field(B#field1)': 'const A()'}),
|
||||
const ConstantData('const C()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '42',
|
||||
'field(C#field2)': 'false',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '87',
|
||||
'field(C#field2)': 'false',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C(field2: true)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '42',
|
||||
'field(C#field2)': 'true',
|
||||
}),
|
||||
const ConstantData('const C.named()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': 'false',
|
||||
'field(C#field2)': 'false',
|
||||
}),
|
||||
const ConstantData('const C.named(87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'C',
|
||||
fields: const {
|
||||
'field(B#field1)': '87',
|
||||
'field(C#field2)': '87',
|
||||
}),
|
||||
]),
|
||||
const TestData('''
|
||||
class A<T> implements B {
|
||||
final field1;
|
||||
const A({this.field1:42});
|
||||
|
@ -153,42 +147,41 @@ class B<S> implements C {
|
|||
class C<U> {
|
||||
const factory C({field1}) = A<B<double>>;
|
||||
}
|
||||
''',
|
||||
const [
|
||||
const ConstantData('const A()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<dynamic>', fields: const {'field(A#field1)': '42'}),
|
||||
const ConstantData(
|
||||
'const A<int>(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<int>', fields: const {'field(A#field1)': '87'}),
|
||||
const ConstantData('const B()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<dynamic>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '42',
|
||||
}),
|
||||
const ConstantData('const B<int>()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<int>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '42',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const B<int>(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<int>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '87',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C<int>(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<double>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '87',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const B<int>.named()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<int>',
|
||||
fields: const {
|
||||
'field(A#field1)': '42',
|
||||
}),
|
||||
]),
|
||||
''', const [
|
||||
const ConstantData('const A()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<dynamic>', fields: const {'field(A#field1)': '42'}),
|
||||
const ConstantData(
|
||||
'const A<int>(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<int>', fields: const {'field(A#field1)': '87'}),
|
||||
const ConstantData('const B()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<dynamic>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '42',
|
||||
}),
|
||||
const ConstantData('const B<int>()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<int>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '42',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const B<int>(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<int>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '87',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const C<int>(field1: 87)', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<B<double>>',
|
||||
fields: const {
|
||||
'field(A#field1)': '87',
|
||||
}),
|
||||
const ConstantData(
|
||||
'const B<int>.named()', ConstantExpressionKind.CONSTRUCTED,
|
||||
type: 'A<int>',
|
||||
fields: const {
|
||||
'field(A#field1)': '42',
|
||||
}),
|
||||
]),
|
||||
];
|
||||
|
||||
main() {
|
||||
|
|
|
@ -32,27 +32,21 @@ Future runTest(String code,
|
|||
|
||||
void main() {
|
||||
asyncTest(() async {
|
||||
await runTest(
|
||||
'''
|
||||
await runTest('''
|
||||
main() {Foo.bar();}
|
||||
class Foo {
|
||||
static void bar() {
|
||||
baz());
|
||||
}
|
||||
}
|
||||
''',
|
||||
error: MessageKind.MISSING_TOKEN_AFTER_THIS,
|
||||
expectedWarningCount: 1);
|
||||
''', error: MessageKind.MISSING_TOKEN_AFTER_THIS, expectedWarningCount: 1);
|
||||
|
||||
await runTest(
|
||||
'''
|
||||
await runTest('''
|
||||
main() {new C(v);}
|
||||
class C {
|
||||
C(v) {
|
||||
throw '');
|
||||
}
|
||||
}''',
|
||||
error: MessageKind.MISSING_TOKEN_AFTER_THIS,
|
||||
expectedWarningCount: 1);
|
||||
}''', error: MessageKind.MISSING_TOKEN_AFTER_THIS, expectedWarningCount: 1);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,69 +14,42 @@ import 'type_test_helper.dart';
|
|||
void main() {
|
||||
asyncTest(() => Future.forEach([
|
||||
() => test("class Class {}", ["Class"]),
|
||||
() => test(
|
||||
"""abstract class A {}
|
||||
class Class extends A {}""",
|
||||
["Class"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class extends A {}""",
|
||||
["Class"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
() => test("""abstract class A {}
|
||||
class Class extends A {}""", ["Class"]),
|
||||
() => test("""class A {}
|
||||
class Class extends A {}""", ["Class"]),
|
||||
() => test("""class A {}
|
||||
class B {}
|
||||
class Class extends A {}""",
|
||||
["Class"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class implements A {}""",
|
||||
["Class"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class extends Object with A {}""",
|
||||
["Class"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class extends A {}""", ["Class"]),
|
||||
() => test("""class A {}
|
||||
class Class implements A {}""", ["Class"]),
|
||||
() => test("""class A {}
|
||||
class Class extends Object with A {}""", ["Class"]),
|
||||
() => test("""class A {}
|
||||
class B {}
|
||||
class Class extends Object with B implements A {}""",
|
||||
["Class"]),
|
||||
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class {}""",
|
||||
["Class", "A"],
|
||||
() => test("""class A {}
|
||||
class Class {}""", ["Class", "A"], ["Class", "A"]),
|
||||
() => test("""class A {}
|
||||
class Class extends A {}""", ["Class", "A"], ["Class", "A"]),
|
||||
() => test("""class A {}
|
||||
class Class implements A {}""", ["Class", "A"],
|
||||
["Class", "A"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class extends A {}""",
|
||||
["Class", "A"],
|
||||
["Class", "A"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class implements A {}""",
|
||||
["Class", "A"],
|
||||
["Class", "A"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
() => test("""class A {}
|
||||
class B extends A {}
|
||||
class Class extends B {}""",
|
||||
["Class", "A"],
|
||||
["Class", "A"]),
|
||||
() => test(
|
||||
"""class A {}
|
||||
class Class extends B {}""", ["Class", "A"], ["Class", "A"]),
|
||||
() => test("""class A {}
|
||||
class B {}
|
||||
class Class extends B with A {}""",
|
||||
["Class", "A"],
|
||||
class Class extends B with A {}""", ["Class", "A"],
|
||||
["Class", "A"]),
|
||||
|
||||
// TODO(johnniwinther): Avoid registration of `Class` as instantiated.
|
||||
() => test(
|
||||
"""class A {}
|
||||
() => test("""class A {}
|
||||
class Class implements A {
|
||||
factory Class() = A;
|
||||
}""",
|
||||
["Class", "A"],
|
||||
["Class"]),
|
||||
}""", ["Class", "A"], ["Class"]),
|
||||
], (f) => f()));
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ import 'compiler_helper.dart';
|
|||
main() {
|
||||
test("unreachable code doesn't crash the compiler", () async {
|
||||
// This test is a regression for Issue #24974
|
||||
String generated = await compile(
|
||||
"""
|
||||
String generated = await compile("""
|
||||
import 'package:js/js.dart';
|
||||
|
||||
@JS() @anonymous
|
||||
|
@ -19,8 +18,7 @@ main() {
|
|||
external factory UniqueLongNameForTesting_A();
|
||||
}
|
||||
main() {}
|
||||
""",
|
||||
returnAll: true);
|
||||
""", returnAll: true);
|
||||
|
||||
// the code should not be included in the output either.
|
||||
expect(generated, isNot(contains("UniqueLongNameForTesting_A")));
|
||||
|
|
|
@ -158,23 +158,18 @@ do {
|
|||
'do #; while ( # )', [stm, 'a'], 'do\n foo();\nwhile (a);'),
|
||||
|
||||
testStatement('switch (#) {}', [eOne], 'switch (1) {\n}'),
|
||||
testStatement(
|
||||
'''
|
||||
testStatement('''
|
||||
switch (#) {
|
||||
case #: { # }
|
||||
}''',
|
||||
[eTrue, eOne, block12],
|
||||
}''', [eTrue, eOne, block12],
|
||||
'switch (true) {\n case 1:\n 1;\n 2;\n}'),
|
||||
testStatement(
|
||||
'''
|
||||
testStatement('''
|
||||
switch (#) {
|
||||
case #: { # }
|
||||
break;
|
||||
case #: { # }
|
||||
default: { # }
|
||||
}''',
|
||||
[eTrue, eOne, block12, eTwo, block12, stm],
|
||||
'''
|
||||
}''', [eTrue, eOne, block12, eTwo, block12, stm], '''
|
||||
switch (true) {
|
||||
case 1:
|
||||
1;
|
||||
|
@ -479,19 +474,13 @@ switch (true) {
|
|||
testStatement('label: {label2: {break label;}}', [],
|
||||
'label:\n label2:\n break label;\n'),
|
||||
// Test dangling else:
|
||||
testStatement(
|
||||
'if (a) {if (b) {foo1();}} else {foo2();}',
|
||||
[],
|
||||
"""
|
||||
testStatement('if (a) {if (b) {foo1();}} else {foo2();}', [], """
|
||||
if (a) {
|
||||
if (b)
|
||||
foo1();
|
||||
} else
|
||||
foo2();"""),
|
||||
testStatement(
|
||||
'if (a) {if (b) {foo1();} else {foo2();}}',
|
||||
[],
|
||||
"""
|
||||
testStatement('if (a) {if (b) {foo1();} else {foo2();}}', [], """
|
||||
if (a)
|
||||
if (b)
|
||||
foo1();
|
||||
|
@ -499,9 +488,7 @@ if (a)
|
|||
foo2();
|
||||
"""),
|
||||
testStatement(
|
||||
'if (a) {if (b) {foo1();} else {foo2();}} else {foo3();}',
|
||||
[],
|
||||
"""
|
||||
'if (a) {if (b) {foo1();} else {foo2();}} else {foo3();}', [], """
|
||||
if (a)
|
||||
if (b)
|
||||
foo1();
|
||||
|
@ -510,9 +497,7 @@ if (a)
|
|||
else
|
||||
foo3();"""),
|
||||
testStatement(
|
||||
'if (a) {while (true) if (b) {foo1();}} else {foo2();}',
|
||||
[],
|
||||
"""
|
||||
'if (a) {while (true) if (b) {foo1();}} else {foo2();}', [], """
|
||||
if (a) {
|
||||
while (true)
|
||||
if (b)
|
||||
|
|
|
@ -23,8 +23,7 @@ testClasses() async {
|
|||
{List<String> directlyInstantiated: const <String>[],
|
||||
List<String> abstractlyInstantiated: const <String>[],
|
||||
List<String> indirectlyInstantiated: const <String>[]}) async {
|
||||
TypeEnvironment env = await TypeEnvironment.create(
|
||||
r"""
|
||||
TypeEnvironment env = await TypeEnvironment.create(r"""
|
||||
@JS()
|
||||
class A {
|
||||
get foo;
|
||||
|
@ -73,13 +72,11 @@ newC() => new C(foo: 2);
|
|||
newD() => new D(foo: 3);
|
||||
newE() => new E(4);
|
||||
newF() => new F(5);
|
||||
""",
|
||||
mainSource: """
|
||||
""", mainSource: """
|
||||
import 'package:js/js.dart';
|
||||
|
||||
$mainSource
|
||||
""",
|
||||
useMockCompiler: false);
|
||||
""", useMockCompiler: false);
|
||||
Map<String, ClassElement> classEnvironment = <String, ClassElement>{};
|
||||
|
||||
ClassElement registerClass(ClassElement cls) {
|
||||
|
|
|
@ -31,9 +31,7 @@ main() {
|
|||
// if (t1 || gee.call$0() === true) gee.call$0();
|
||||
// if (t1 || gee.call$0() === true) gee.call$0();
|
||||
compileAndDoNotMatchFuzzy(
|
||||
TEST_ONE,
|
||||
'foo',
|
||||
r"""var x = [a-zA-Z0-9$.]+\(\) == true;
|
||||
TEST_ONE, 'foo', r"""var x = [a-zA-Z0-9$.]+\(\) == true;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;"""),
|
||||
|
||||
|
@ -42,10 +40,7 @@ main() {
|
|||
// if (t1) bar.call$0();
|
||||
// if (t1 || bar.call$0() === true) bar.call$0();
|
||||
// if (t1 || bar.call$0() === true) bar.call$0();
|
||||
compileAndMatchFuzzy(
|
||||
TEST_TWO,
|
||||
'foo',
|
||||
r"""var x = x == null;
|
||||
compileAndMatchFuzzy(TEST_TWO, 'foo', r"""var x = x == null;
|
||||
if \(x\) [^;]+;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;"""),
|
||||
|
|
|
@ -163,9 +163,7 @@ void checkMemberCount(ResolutionInterfaceType cls, int expectedCount,
|
|||
}
|
||||
|
||||
void testClassMembers() {
|
||||
asyncTest(() => TypeEnvironment
|
||||
.create(
|
||||
r"""
|
||||
asyncTest(() => TypeEnvironment.create(r"""
|
||||
abstract class A {
|
||||
int field;
|
||||
final finalField = 0;
|
||||
|
@ -189,9 +187,7 @@ void testClassMembers() {
|
|||
class C<S> extends B<S> {}
|
||||
class D extends C<int> {}
|
||||
class E extends D {}
|
||||
""",
|
||||
useMockCompiler: false)
|
||||
.then((env) {
|
||||
""", useMockCompiler: false).then((env) {
|
||||
ResolutionInterfaceType bool_ = env['bool'];
|
||||
ResolutionInterfaceType String_ = env['String'];
|
||||
ResolutionInterfaceType int_ = env['int'];
|
||||
|
|
|
@ -12,8 +12,7 @@ import 'memory_compiler.dart';
|
|||
import 'memory_source_file_helper.dart';
|
||||
|
||||
const List<Test> TESTS = const <Test>[
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class A { A(b); }
|
||||
class B extends A {
|
||||
a() {}
|
||||
|
@ -24,14 +23,12 @@ class B extends A {
|
|||
|
||||
var members;
|
||||
}
|
||||
main() => new B();''',
|
||||
const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
main() => new B();''', const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
class B extends A {
|
||||
^^^^^^^^^^^^^^^^^'''
|
||||
}),
|
||||
const Test(
|
||||
'''
|
||||
}),
|
||||
const Test('''
|
||||
class I {}
|
||||
class A { A(b); }
|
||||
class B extends A implements I {
|
||||
|
@ -43,14 +40,12 @@ class B extends A implements I {
|
|||
|
||||
var members;
|
||||
}
|
||||
main() => new B();''',
|
||||
const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
main() => new B();''', const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
class B extends A implements I {
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''
|
||||
}),
|
||||
const Test(
|
||||
'''
|
||||
}),
|
||||
const Test('''
|
||||
class M<T> {}
|
||||
class A { A(b); }
|
||||
class B extends A with M<int> {
|
||||
|
@ -62,14 +57,12 @@ class B extends A with M<int> {
|
|||
|
||||
var members;
|
||||
}
|
||||
main() => new B();''',
|
||||
const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
main() => new B();''', const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
class B extends A with M<int> {
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''
|
||||
}),
|
||||
const Test(
|
||||
'''
|
||||
}),
|
||||
const Test('''
|
||||
class A { A(b); }
|
||||
class B
|
||||
extends A {
|
||||
|
@ -81,43 +74,37 @@ class B
|
|||
|
||||
var members;
|
||||
}
|
||||
main() => new B();''',
|
||||
const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
main() => new B();''', const {
|
||||
MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
|
||||
class B
|
||||
extends A {
|
||||
'''
|
||||
}),
|
||||
const Test(
|
||||
'''
|
||||
}),
|
||||
const Test('''
|
||||
void foo(int a) {
|
||||
// a
|
||||
// non-empty
|
||||
// body
|
||||
}
|
||||
main() => foo('');''',
|
||||
const {
|
||||
MessageKind.THIS_IS_THE_METHOD: '''
|
||||
main() => foo('');''', const {
|
||||
MessageKind.THIS_IS_THE_METHOD: '''
|
||||
void foo(int a) {
|
||||
^^^^^^^^^^^^^^^'''
|
||||
}),
|
||||
const Test(
|
||||
'''
|
||||
}),
|
||||
const Test('''
|
||||
void foo(int a,
|
||||
int b) {
|
||||
// a
|
||||
// non-empty
|
||||
// body
|
||||
}
|
||||
main() => foo('', 0);''',
|
||||
const {
|
||||
MessageKind.THIS_IS_THE_METHOD: '''
|
||||
main() => foo('', 0);''', const {
|
||||
MessageKind.THIS_IS_THE_METHOD: '''
|
||||
void foo(int a,
|
||||
int b) {
|
||||
'''
|
||||
}),
|
||||
const Test(
|
||||
'''
|
||||
}),
|
||||
const Test('''
|
||||
class A {
|
||||
int foo() {
|
||||
// a
|
||||
|
@ -133,15 +120,14 @@ class B extends A {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
main() => new B();''',
|
||||
const {
|
||||
MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER: '''
|
||||
main() => new B();''', const {
|
||||
MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER: '''
|
||||
int get foo {
|
||||
^^^^^^^^^^^''',
|
||||
MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT: '''
|
||||
MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT: '''
|
||||
int foo() {
|
||||
^^^^^^^^^'''
|
||||
}),
|
||||
}),
|
||||
];
|
||||
|
||||
class Test {
|
||||
|
|
|
@ -16,9 +16,7 @@ void main() {
|
|||
}
|
||||
|
||||
void testMixinSupertypes() {
|
||||
asyncTest(() => TypeEnvironment
|
||||
.create(
|
||||
r"""
|
||||
asyncTest(() => TypeEnvironment.create(r"""
|
||||
class S<S_T> {}
|
||||
class M1<M1_T> {}
|
||||
class M2<M2_T> {}
|
||||
|
@ -26,9 +24,7 @@ void testMixinSupertypes() {
|
|||
|
||||
class C1<C1_T> extends S<C1_T> with M1<C1_T>, M2<C1_T>, M3<C1_T> {}
|
||||
class C2<C2_T> = S<C2_T> with M1<C2_T>, M2<C2_T>, M3<C2_T>;
|
||||
""",
|
||||
expectNoWarningsOrErrors: true)
|
||||
.then((env) {
|
||||
""", expectNoWarningsOrErrors: true).then((env) {
|
||||
ClassElement Object = env.getElement('Object');
|
||||
ClassElement S = env.getElement('S');
|
||||
ClassElement M1 = env.getElement('M1');
|
||||
|
@ -75,9 +71,7 @@ void testMixinSupertypes() {
|
|||
}
|
||||
|
||||
void testNonTrivialSubstitutions() {
|
||||
asyncTest(() => TypeEnvironment
|
||||
.create(
|
||||
r"""
|
||||
asyncTest(() => TypeEnvironment.create(r"""
|
||||
class _ {}
|
||||
class A<A_T> {}
|
||||
class B<B_T, B_S> {}
|
||||
|
@ -93,9 +87,7 @@ void testNonTrivialSubstitutions() {
|
|||
|
||||
class F1<F1_T> extends A<_> with B<_, B<F1_T, _>> {}
|
||||
class F2<F2_T> = A<_> with B<_, B<F2_T, _>>;
|
||||
""",
|
||||
expectNoWarningsOrErrors: true)
|
||||
.then((env) {
|
||||
""", expectNoWarningsOrErrors: true).then((env) {
|
||||
ResolutionDartType _dynamic = env['dynamic'];
|
||||
ResolutionDartType _ = env['_'];
|
||||
|
||||
|
|
|
@ -46,8 +46,7 @@ class NoSuchMethodTest {
|
|||
}
|
||||
|
||||
const List<NoSuchMethodTest> TESTS = const <NoSuchMethodTest>[
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
foo() => 3;
|
||||
noSuchMethod(x) => super.noSuchMethod(x);
|
||||
|
@ -55,12 +54,10 @@ class A {
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest("""
|
||||
class A extends B {
|
||||
foo() => 3;
|
||||
noSuchMethod(x) => super.noSuchMethod(x);
|
||||
|
@ -69,12 +66,10 @@ class B {}
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest("""
|
||||
class A extends B {
|
||||
foo() => 3;
|
||||
noSuchMethod(x) {
|
||||
|
@ -85,12 +80,10 @@ class B {}
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest("""
|
||||
class A extends B {
|
||||
foo() => 3;
|
||||
noSuchMethod(x) => super.noSuchMethod(x);
|
||||
|
@ -101,14 +94,12 @@ class B {
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A',
|
||||
superClassName: 'B', hasForwardingSyntax: true, isDefault: true),
|
||||
const NoSuchMethodInfo('B', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A',
|
||||
superClassName: 'B', hasForwardingSyntax: true, isDefault: true),
|
||||
const NoSuchMethodInfo('B', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest("""
|
||||
class A extends B {
|
||||
foo() => 3;
|
||||
noSuchMethod(x) => super.noSuchMethod(x);
|
||||
|
@ -119,66 +110,53 @@ class B {
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A',
|
||||
superClassName: 'B', hasForwardingSyntax: true, isThrowing: true),
|
||||
const NoSuchMethodInfo('B', hasThrowingSyntax: true, isThrowing: true),
|
||||
],
|
||||
isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A',
|
||||
superClassName: 'B', hasForwardingSyntax: true, isThrowing: true),
|
||||
const NoSuchMethodInfo('B', hasThrowingSyntax: true, isThrowing: true),
|
||||
], isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(x) => 3;
|
||||
}
|
||||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true),
|
||||
],
|
||||
isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true),
|
||||
], isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(x, [y]) => super.noSuchMethod(x);
|
||||
}
|
||||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(x, [y]) => super.noSuchMethod(x, y);
|
||||
}
|
||||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true),
|
||||
],
|
||||
isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true),
|
||||
], isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(x, y) => super.noSuchMethod(x);
|
||||
}
|
||||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A',
|
||||
hasForwardingSyntax: true, isNotApplicable: true),
|
||||
]),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A',
|
||||
hasForwardingSyntax: true, isNotApplicable: true),
|
||||
]),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(Invocation x) {
|
||||
throw new UnsupportedException();
|
||||
|
@ -187,13 +165,10 @@ class A {
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasThrowingSyntax: true, isThrowing: true),
|
||||
],
|
||||
isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasThrowingSyntax: true, isThrowing: true),
|
||||
], isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(Invocation x) {
|
||||
print('foo');
|
||||
|
@ -203,13 +178,10 @@ class A {
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true),
|
||||
],
|
||||
isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true),
|
||||
], isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(Invocation x) {
|
||||
return toString();
|
||||
|
@ -218,23 +190,19 @@ class A {
|
|||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true),
|
||||
],
|
||||
isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest(
|
||||
"""
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true),
|
||||
], isNoSuchMethodUsed: true),
|
||||
const NoSuchMethodTest("""
|
||||
class A {
|
||||
noSuchMethod(x) => super.noSuchMethod(x) as dynamic;
|
||||
}
|
||||
main() {
|
||||
print(new A().foo());
|
||||
}
|
||||
""",
|
||||
const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
""", const <NoSuchMethodInfo>[
|
||||
const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true),
|
||||
]),
|
||||
];
|
||||
|
||||
main() {
|
||||
|
|
|
@ -78,8 +78,7 @@ Future testRequiredParameters() {
|
|||
method(b, a, d, c) => null; // testRequiredParameters:4
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method() => null; // testRequiredParameters:5
|
||||
}
|
||||
|
@ -89,8 +88,7 @@ Future testRequiredParameters() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method() => null; // testRequiredParameters:7
|
||||
}
|
||||
|
@ -100,8 +98,7 @@ Future testRequiredParameters() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(a, b, c) => null; // testRequiredParameters:9
|
||||
}
|
||||
|
@ -148,8 +145,7 @@ Future testPositionalParameters() {
|
|||
method([a]) => null; // testPositionalParameters:8
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(a) => null; // testPositionalParameters:9
|
||||
}
|
||||
|
@ -159,8 +155,7 @@ Future testPositionalParameters() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(a, [b]) => null; // testPositionalParameters:11
|
||||
}
|
||||
|
@ -170,8 +165,7 @@ Future testPositionalParameters() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(a, [b]) => null; // testPositionalParameters:13
|
||||
}
|
||||
|
@ -181,8 +175,7 @@ Future testPositionalParameters() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(a, b, [c, d, e]) => null; // testPositionalParameters:15
|
||||
}
|
||||
|
@ -229,8 +222,7 @@ Future testNamedParameters() {
|
|||
method(e, {b, c, a, d}) => null; // testNamedParameters:8
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method({a}) => null; // testNamedParameters:9
|
||||
}
|
||||
|
@ -240,8 +232,7 @@ Future testNamedParameters() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method({a, b}) => null; // testNamedParameters:11
|
||||
}
|
||||
|
@ -251,8 +242,7 @@ Future testNamedParameters() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method({a, b, c, d}) => null; // testNamedParameters:13
|
||||
}
|
||||
|
@ -312,8 +302,7 @@ Future testNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int method() => null; // testNotSubtype:11
|
||||
}
|
||||
|
@ -348,8 +337,7 @@ Future testNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(int a) => null; // testNotSubtype:19
|
||||
}
|
||||
|
@ -361,8 +349,7 @@ Future testNotSubtype() {
|
|||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
|
||||
// TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(int a) => null; // testNotSubtype:23
|
||||
}
|
||||
|
@ -378,8 +365,7 @@ Future testNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(num a) => null; // testNotSubtype:29
|
||||
}
|
||||
|
@ -395,8 +381,7 @@ Future testNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method(int a) => null; // testNotSubtype:26
|
||||
}
|
||||
|
@ -408,15 +393,13 @@ Future testNotSubtype() {
|
|||
class Class implements C {
|
||||
method(String a) => null; // testNotSubtype:28
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -458,8 +441,7 @@ Future testGetterNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int get getter => null; // testGetterNotSubtype:9
|
||||
}
|
||||
|
@ -482,8 +464,7 @@ Future testGetterNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int get getter => null; // testGetterNotSubtype:14
|
||||
}
|
||||
|
@ -497,8 +478,7 @@ Future testGetterNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int get getter => null; // testGetterNotSubtype:17
|
||||
}
|
||||
|
@ -508,18 +488,15 @@ Future testGetterNotSubtype() {
|
|||
class Class extends A implements B {
|
||||
double get getter => null; // testGetterNotSubtype:19
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_GETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_GETTER
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER
|
||||
]),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int get getter => null; // testGetterNotSubtype:20
|
||||
}
|
||||
|
@ -529,19 +506,16 @@ Future testGetterNotSubtype() {
|
|||
class Class implements A, B {
|
||||
double get getter => null; // testGetterNotSubtype:22
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_GETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_GETTER
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER
|
||||
]),
|
||||
|
||||
// TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int get getter => null; // testGetterNotSubtype:23
|
||||
}
|
||||
|
@ -557,8 +531,7 @@ Future testGetterNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int get getter => null; // testGetterNotSubtype:26
|
||||
}
|
||||
|
@ -570,15 +543,13 @@ Future testGetterNotSubtype() {
|
|||
class Class implements C {
|
||||
String get getter => null; // testGetterNotSubtype:28
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_GETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_GETTER
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -614,8 +585,7 @@ Future testGenericNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A<T> {
|
||||
method(T t) => null; // testGenericNotSubtype:8
|
||||
}
|
||||
|
@ -638,8 +608,7 @@ Future testGenericNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A<T> {
|
||||
method(T t) => null; // testGenericNotSubtype:12
|
||||
}
|
||||
|
@ -653,8 +622,7 @@ Future testGenericNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A<T> {
|
||||
method(T t) => null; // testGenericNotSubtype:15
|
||||
}
|
||||
|
@ -664,18 +632,15 @@ Future testGenericNotSubtype() {
|
|||
class Class extends A<int> implements B<String> {
|
||||
method(double d) => null; // testGenericNotSubtype:17
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A<T> {
|
||||
method(T t) => null; // testGenericNotSubtype:18
|
||||
}
|
||||
|
@ -685,19 +650,16 @@ Future testGenericNotSubtype() {
|
|||
class Class implements A<int>, B<String> {
|
||||
method(double d) => null; // testGenericNotSubtype:20
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
|
||||
// TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A<T> {
|
||||
method(T t) => null; // testGenericNotSubtype:21
|
||||
}
|
||||
|
@ -713,8 +675,7 @@ Future testGenericNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A<T> {
|
||||
method(T t) => null; // testGenericNotSubtype:24
|
||||
}
|
||||
|
@ -726,15 +687,13 @@ Future testGenericNotSubtype() {
|
|||
class Class implements C {
|
||||
method(String s) => null; // testGenericNotSubtype:26
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_METHOD,
|
||||
MessageKind.INVALID_OVERRIDE_METHOD
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD,
|
||||
MessageKind.INVALID_OVERRIDDEN_METHOD
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -803,8 +762,7 @@ Future testSetterNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set setter(int _) => null; // testSetterNotSubtype:15
|
||||
}
|
||||
|
@ -827,8 +785,7 @@ Future testSetterNotSubtype() {
|
|||
}
|
||||
"""),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set setter(int _) => null; // testSetterNotSubtype:20
|
||||
}
|
||||
|
@ -842,8 +799,7 @@ Future testSetterNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set setter(int _) => null; // testSetterNotSubtype:23
|
||||
}
|
||||
|
@ -853,18 +809,15 @@ Future testSetterNotSubtype() {
|
|||
class Class extends A implements B {
|
||||
set setter(double _) => null; // testSetterNotSubtype:25
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set setter(int _) => null; // testSetterNotSubtype:26
|
||||
}
|
||||
|
@ -874,19 +827,16 @@ Future testSetterNotSubtype() {
|
|||
class Class implements A, B {
|
||||
set setter(double _) => null; // testSetterNotSubtype:28
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
|
||||
// TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set setter(int _) => null; // testSetterNotSubtype:29
|
||||
}
|
||||
|
@ -902,8 +852,7 @@ Future testSetterNotSubtype() {
|
|||
warnings: MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set setter(int _) => null; // testSetterNotSubtype:32
|
||||
}
|
||||
|
@ -915,15 +864,13 @@ Future testSetterNotSubtype() {
|
|||
class Class implements C {
|
||||
set setter(String _) => null; // testSetterNotSubtype:34
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_SETTER,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -953,8 +900,7 @@ Future testFieldNotSubtype() {
|
|||
num field; // testFieldNotSubtype:6
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int field; // testFieldNotSubtype:7
|
||||
}
|
||||
|
@ -983,8 +929,7 @@ Future testFieldNotSubtype() {
|
|||
int get field => null; // testFieldNotSubtype:13
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
num field; // testFieldNotSubtype:14
|
||||
}
|
||||
|
@ -994,8 +939,7 @@ Future testFieldNotSubtype() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
num get field => null; // testFieldNotSubtype:16
|
||||
}
|
||||
|
@ -1037,8 +981,7 @@ Future testFieldNotSubtype() {
|
|||
num field; // testFieldNotSubtype:24
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
num field; // testFieldNotSubtype:25
|
||||
}
|
||||
|
@ -1048,8 +991,7 @@ Future testFieldNotSubtype() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set field(num _) {} // testFieldNotSubtype:27
|
||||
}
|
||||
|
@ -1059,8 +1001,7 @@ Future testFieldNotSubtype() {
|
|||
""",
|
||||
warnings: MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD,
|
||||
infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
int field; // testFieldNotSubtype:29
|
||||
}
|
||||
|
@ -1068,17 +1009,14 @@ Future testFieldNotSubtype() {
|
|||
String get field => null; // testFieldNotSubtype:30
|
||||
void set field(String s) {} // testFieldNotSubtype:31
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_FIELD,
|
||||
MessageKind.INVALID_OVERRIDDEN_FIELD
|
||||
]),
|
||||
check(
|
||||
"""
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
|
||||
MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_FIELD,
|
||||
MessageKind.INVALID_OVERRIDDEN_FIELD
|
||||
]),
|
||||
check("""
|
||||
class A {
|
||||
String get field => null; // testFieldNotSubtype:32
|
||||
void set field(String s) {} // testFieldNotSubtype:33
|
||||
|
@ -1086,22 +1024,19 @@ Future testFieldNotSubtype() {
|
|||
class Class implements A {
|
||||
int field; // testFieldNotSubtype:34
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD
|
||||
],
|
||||
infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD,
|
||||
MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD
|
||||
], infos: [
|
||||
MessageKind.INVALID_OVERRIDDEN_GETTER,
|
||||
MessageKind.INVALID_OVERRIDDEN_SETTER
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
Future testMixedOverride() {
|
||||
return Future.wait([
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
var member; // testMixedOverride:1
|
||||
}
|
||||
|
@ -1111,8 +1046,7 @@ Future testMixedOverride() {
|
|||
""",
|
||||
errors: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD,
|
||||
infos: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
member() {} // testMixedOverride:3
|
||||
}
|
||||
|
@ -1122,8 +1056,7 @@ Future testMixedOverride() {
|
|||
""",
|
||||
errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD,
|
||||
infos: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
get member => null; // testMixedOverride:5
|
||||
}
|
||||
|
@ -1133,8 +1066,7 @@ Future testMixedOverride() {
|
|||
""",
|
||||
errors: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD,
|
||||
infos: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
member() {} // testMixedOverride:7
|
||||
}
|
||||
|
@ -1306,8 +1238,7 @@ Future testAbstractMethods() {
|
|||
method([a]) {} // testAbstractMethod:8
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
abstract class A {
|
||||
method(); // testAbstractMethod:9
|
||||
}
|
||||
|
@ -1316,8 +1247,7 @@ Future testAbstractMethods() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
abstract class A {
|
||||
get getter; // testAbstractMethod:10
|
||||
}
|
||||
|
@ -1326,8 +1256,7 @@ Future testAbstractMethods() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
abstract class A {
|
||||
set setter(_); // testAbstractMethod:11
|
||||
}
|
||||
|
@ -1441,8 +1370,7 @@ Future testAbstractMethods() {
|
|||
method([a]) {} // testAbstractMethod:27
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method() {} // testAbstractMethod:28
|
||||
}
|
||||
|
@ -1461,24 +1389,20 @@ Future testAbstractMethods() {
|
|||
class Class extends A implements B {
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
var member; // testAbstractMethod:31
|
||||
}
|
||||
class Class implements A {
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.UNIMPLEMENTED_GETTER_ONE,
|
||||
MessageKind.UNIMPLEMENTED_SETTER_ONE
|
||||
],
|
||||
infos: [
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
|
||||
]),
|
||||
check(
|
||||
"""
|
||||
""", warnings: [
|
||||
MessageKind.UNIMPLEMENTED_GETTER_ONE,
|
||||
MessageKind.UNIMPLEMENTED_SETTER_ONE
|
||||
], infos: [
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
|
||||
]),
|
||||
check("""
|
||||
class A {
|
||||
var member; // testAbstractMethod:32
|
||||
}
|
||||
|
@ -1488,19 +1412,16 @@ Future testAbstractMethods() {
|
|||
}
|
||||
class Class implements A, B {
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.UNIMPLEMENTED_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_SETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
|
||||
]),
|
||||
check(
|
||||
"""
|
||||
""", warnings: [
|
||||
MessageKind.UNIMPLEMENTED_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_SETTER
|
||||
], infos: [
|
||||
MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
|
||||
]),
|
||||
check("""
|
||||
class A {
|
||||
var member; // testAbstractMethod:35
|
||||
}
|
||||
|
@ -1509,19 +1430,16 @@ Future testAbstractMethods() {
|
|||
}
|
||||
class Class implements A, B {
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.UNIMPLEMENTED_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_SETTER
|
||||
],
|
||||
infos: [
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
|
||||
]),
|
||||
check(
|
||||
"""
|
||||
""", warnings: [
|
||||
MessageKind.UNIMPLEMENTED_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_SETTER
|
||||
], infos: [
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER,
|
||||
MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
|
||||
]),
|
||||
check("""
|
||||
class A {
|
||||
get member => 0; // testAbstractMethod:37
|
||||
}
|
||||
|
@ -1530,8 +1448,7 @@ Future testAbstractMethods() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
set member(_) {} // testAbstractMethod:38
|
||||
}
|
||||
|
@ -1540,8 +1457,7 @@ Future testAbstractMethods() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
var member; // testAbstractMethod:39
|
||||
}
|
||||
|
@ -1551,8 +1467,7 @@ Future testAbstractMethods() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
var field; // testAbstractMethod:40
|
||||
}
|
||||
|
@ -1562,8 +1477,7 @@ Future testAbstractMethods() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
var member; // testAbstractMethod:42
|
||||
}
|
||||
|
@ -1621,8 +1535,7 @@ Future testNoSuchMethod() {
|
|||
method(); // testNoSuchMethod:5
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
abstract class A {
|
||||
method(); // testNoSuchMethod:6
|
||||
}
|
||||
|
@ -1631,8 +1544,7 @@ Future testNoSuchMethod() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
abstract class A {
|
||||
method(); // testNoSuchMethod:7
|
||||
}
|
||||
|
@ -1650,8 +1562,7 @@ Future testNoSuchMethod() {
|
|||
noSuchMethod(_) => null;
|
||||
}
|
||||
"""),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method() {} // testNoSuchMethod:9
|
||||
}
|
||||
|
@ -1660,8 +1571,7 @@ Future testNoSuchMethod() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method() {} // testNoSuchMethod:10
|
||||
}
|
||||
|
@ -1670,8 +1580,7 @@ Future testNoSuchMethod() {
|
|||
""",
|
||||
warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
|
||||
infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
class A {
|
||||
method() {} // testNoSuchMethod:11
|
||||
}
|
||||
|
|
|
@ -135,12 +135,10 @@ Future testPatchFunction() async {
|
|||
}
|
||||
|
||||
Future testPatchFunctionMetadata() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
const a = 0;
|
||||
@a external test();
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
const _b = 1;
|
||||
@patch @_b test() {}
|
||||
""");
|
||||
|
@ -220,13 +218,11 @@ Future testPatchFunctionGenericDifferentNames() async {
|
|||
}
|
||||
|
||||
Future testPatchConstructor() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
external Class();
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
@patch Class();
|
||||
}
|
||||
|
@ -260,15 +256,13 @@ Future testPatchConstructor() async {
|
|||
}
|
||||
|
||||
Future testPatchRedirectingConstructor() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
Class(x) : this._(x, false);
|
||||
|
||||
external Class._(x, y);
|
||||
}
|
||||
""",
|
||||
r"""
|
||||
""", r"""
|
||||
@patch class Class {
|
||||
@patch Class._(x, y) { print('$x,$y'); }
|
||||
}
|
||||
|
@ -306,13 +300,11 @@ Future testPatchRedirectingConstructor() async {
|
|||
}
|
||||
|
||||
Future testPatchMember() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
external String toString();
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
@patch String toString() => 'string';
|
||||
}
|
||||
|
@ -338,13 +330,11 @@ Future testPatchMember() async {
|
|||
}
|
||||
|
||||
Future testPatchGetter() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
external int get field;
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
@patch int get field => 5;
|
||||
}
|
||||
|
@ -366,13 +356,11 @@ Future testPatchGetter() async {
|
|||
}
|
||||
|
||||
Future testRegularMember() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
void regular() {}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
}
|
||||
""");
|
||||
|
@ -397,12 +385,10 @@ Future testRegularMember() async {
|
|||
}
|
||||
|
||||
Future testInjectedMember() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
void _injected() {}
|
||||
}
|
||||
|
@ -428,12 +414,10 @@ Future testInjectedMember() async {
|
|||
}
|
||||
|
||||
Future testInjectedPublicMember() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
void injected() {}
|
||||
}
|
||||
|
@ -495,8 +479,7 @@ Future testInjectedPublicFunction() async {
|
|||
}
|
||||
|
||||
Future testPatchSignatureCheck() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
external String method1();
|
||||
external void method2(String str);
|
||||
|
@ -510,8 +493,7 @@ Future testPatchSignatureCheck() async {
|
|||
external void method10([String str]);
|
||||
external void method11({String str});
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
@patch int method1() => 0;
|
||||
@patch void method2() {}
|
||||
|
@ -571,11 +553,9 @@ Future testPatchSignatureCheck() async {
|
|||
}
|
||||
|
||||
Future testExternalWithoutImplementationTopLevel() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external void foo();
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
// @patch void foo() {}
|
||||
""");
|
||||
dynamic function = ensure(
|
||||
|
@ -593,13 +573,11 @@ Future testExternalWithoutImplementationTopLevel() async {
|
|||
}
|
||||
|
||||
Future testExternalWithoutImplementationMember() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
external void foo();
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
// @patch void foo() {}
|
||||
}
|
||||
|
@ -623,11 +601,9 @@ Future testExternalWithoutImplementationMember() async {
|
|||
}
|
||||
|
||||
Future testIsSubclass() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class A {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class A {}
|
||||
""");
|
||||
ClassElement cls = ensure(
|
||||
|
@ -640,11 +616,9 @@ Future testIsSubclass() async {
|
|||
}
|
||||
|
||||
Future testPatchNonExistingTopLevel() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
// class Class {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {}
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -657,11 +631,9 @@ Future testPatchNonExistingTopLevel() async {
|
|||
}
|
||||
|
||||
Future testPatchNonExistingMember() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
@patch void foo() {}
|
||||
}
|
||||
|
@ -681,11 +653,9 @@ Future testPatchNonExistingMember() async {
|
|||
}
|
||||
|
||||
Future testPatchNonPatchablePatch() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external get foo;
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch var foo;
|
||||
""");
|
||||
ensure(compiler, "foo", compiler.resolution.commonElements.coreLibrary.find);
|
||||
|
@ -700,11 +670,9 @@ Future testPatchNonPatchablePatch() async {
|
|||
}
|
||||
|
||||
Future testPatchNonPatchableOrigin() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external var foo;
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch get foo => 0;
|
||||
""");
|
||||
ensure(compiler, "foo", compiler.resolution.commonElements.coreLibrary.find);
|
||||
|
@ -724,11 +692,9 @@ Future testPatchNonPatchableOrigin() async {
|
|||
}
|
||||
|
||||
Future testPatchNonExternalTopLevel() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
void foo() {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch void foo() {}
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -744,13 +710,11 @@ Future testPatchNonExternalTopLevel() async {
|
|||
}
|
||||
|
||||
Future testPatchNonExternalMember() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class Class {
|
||||
void foo() {}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {
|
||||
@patch void foo() {}
|
||||
}
|
||||
|
@ -773,11 +737,9 @@ Future testPatchNonExternalMember() async {
|
|||
}
|
||||
|
||||
Future testPatchNonClass() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external void Class() {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class Class {}
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -793,11 +755,9 @@ Future testPatchNonClass() async {
|
|||
}
|
||||
|
||||
Future testPatchNonGetter() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external void foo() {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch get foo => 0;
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -813,11 +773,9 @@ Future testPatchNonGetter() async {
|
|||
}
|
||||
|
||||
Future testPatchNoGetter() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external set foo(var value) {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch get foo => 0;
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -833,11 +791,9 @@ Future testPatchNoGetter() async {
|
|||
}
|
||||
|
||||
Future testPatchNonSetter() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external void foo() {}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch set foo(var value) {}
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -853,11 +809,9 @@ Future testPatchNonSetter() async {
|
|||
}
|
||||
|
||||
Future testPatchNoSetter() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external get foo;
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch set foo(var value) {}
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -873,11 +827,9 @@ Future testPatchNoSetter() async {
|
|||
}
|
||||
|
||||
Future testPatchNonFunction() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
external get foo;
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch void foo() {}
|
||||
""");
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
|
@ -893,28 +845,23 @@ Future testPatchNonFunction() async {
|
|||
}
|
||||
|
||||
Future testPatchAndSelector() async {
|
||||
dynamic compiler = await applyPatch(
|
||||
"""
|
||||
dynamic compiler = await applyPatch("""
|
||||
class A {
|
||||
external void clear();
|
||||
}
|
||||
class B extends A {
|
||||
}
|
||||
""",
|
||||
"""
|
||||
""", """
|
||||
@patch class A {
|
||||
int method() => 0;
|
||||
@patch void clear() {}
|
||||
}
|
||||
""",
|
||||
main: """
|
||||
""", main: """
|
||||
main () {
|
||||
new A(); // ensure A and B are instantiated
|
||||
new B();
|
||||
}
|
||||
""",
|
||||
runCompiler: true,
|
||||
analyzeOnly: true);
|
||||
""", runCompiler: true, analyzeOnly: true);
|
||||
compiler.closeResolution(
|
||||
compiler.frontendStrategy.elementEnvironment.mainFunction);
|
||||
ClosedWorld world = compiler.resolutionWorldBuilder.closedWorldForTesting;
|
||||
|
@ -979,22 +926,18 @@ Future testAnalyzeAllInjectedMembers() async {
|
|||
|
||||
await expect('String s = 0;', MessageKind.NOT_ASSIGNABLE);
|
||||
await expect('void method() { String s = 0; }', MessageKind.NOT_ASSIGNABLE);
|
||||
await expect(
|
||||
'''
|
||||
await expect('''
|
||||
class Class {
|
||||
String s = 0;
|
||||
}
|
||||
''',
|
||||
MessageKind.NOT_ASSIGNABLE);
|
||||
await expect(
|
||||
'''
|
||||
''', MessageKind.NOT_ASSIGNABLE);
|
||||
await expect('''
|
||||
class Class {
|
||||
void method() {
|
||||
String s = 0;
|
||||
}
|
||||
}
|
||||
''',
|
||||
MessageKind.NOT_ASSIGNABLE);
|
||||
''', MessageKind.NOT_ASSIGNABLE);
|
||||
}
|
||||
|
||||
Future testEffectiveTarget() async {
|
||||
|
|
|
@ -35,11 +35,9 @@ test(String input, [Map<String, Map<String, String>> expectedOutput]) {
|
|||
|
||||
main() {
|
||||
// Empty file.
|
||||
test(
|
||||
"""
|
||||
test("""
|
||||
# Nothing here
|
||||
""",
|
||||
{});
|
||||
""", {});
|
||||
|
||||
// Text outside section.
|
||||
test("""
|
||||
|
@ -82,36 +80,30 @@ name:value
|
|||
""");
|
||||
|
||||
// Ok.
|
||||
test(
|
||||
"""
|
||||
test("""
|
||||
[AA]
|
||||
name:value
|
||||
[BB]
|
||||
name:value
|
||||
name2:value2
|
||||
""",
|
||||
{
|
||||
"AA": {"name": "value"},
|
||||
"BB": {"name": "value", "name2": "value2"}
|
||||
});
|
||||
""", {
|
||||
"AA": {"name": "value"},
|
||||
"BB": {"name": "value", "name2": "value2"}
|
||||
});
|
||||
|
||||
// Ok, file not ending in newline.
|
||||
test(
|
||||
"""
|
||||
test("""
|
||||
[AA]
|
||||
name:value""",
|
||||
{
|
||||
"A": {"name": "value"}
|
||||
});
|
||||
name:value""", {
|
||||
"A": {"name": "value"}
|
||||
});
|
||||
|
||||
// Ok, whitespace is trimmed away.
|
||||
test(
|
||||
"""
|
||||
test("""
|
||||
[ AA ]
|
||||
name\t: value """,
|
||||
{
|
||||
"A": {"name": "value"}
|
||||
});
|
||||
name\t: value """, {
|
||||
"A": {"name": "value"}
|
||||
});
|
||||
|
||||
// Duplicate property name.
|
||||
test("""
|
||||
|
|
|
@ -1299,39 +1299,32 @@ testConstConstructorAndNonFinalFields() {
|
|||
|
||||
testCantAssignMethods() {
|
||||
// Can't override local functions
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() {
|
||||
mname() { mname = 2; };
|
||||
mname();
|
||||
}
|
||||
''',
|
||||
[MessageKind.ASSIGNING_METHOD]);
|
||||
''', [MessageKind.ASSIGNING_METHOD]);
|
||||
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() {
|
||||
mname() { };
|
||||
mname = 3;
|
||||
}
|
||||
''',
|
||||
[MessageKind.ASSIGNING_METHOD]);
|
||||
''', [MessageKind.ASSIGNING_METHOD]);
|
||||
|
||||
// Can't override top-level functions
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
m() {}
|
||||
main() { m = 4; }
|
||||
''',
|
||||
[
|
||||
MessageKind.ASSIGNING_METHOD,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.NOT_ASSIGNABLE
|
||||
]);
|
||||
''', [
|
||||
MessageKind.ASSIGNING_METHOD,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.NOT_ASSIGNABLE
|
||||
]);
|
||||
|
||||
// Can't override instance methods
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() { new B().bar(); }
|
||||
class B {
|
||||
mname() {}
|
||||
|
@ -1339,10 +1332,8 @@ testCantAssignMethods() {
|
|||
mname = () => null;
|
||||
}
|
||||
}
|
||||
''',
|
||||
[MessageKind.UNDEFINED_SETTER]);
|
||||
checkWarningOn(
|
||||
'''
|
||||
''', [MessageKind.UNDEFINED_SETTER]);
|
||||
checkWarningOn('''
|
||||
main() { new B().bar(); }
|
||||
class B {
|
||||
mname() {}
|
||||
|
@ -1350,12 +1341,10 @@ testCantAssignMethods() {
|
|||
this.mname = () => null;
|
||||
}
|
||||
}
|
||||
''',
|
||||
[MessageKind.UNDEFINED_SETTER]);
|
||||
''', [MessageKind.UNDEFINED_SETTER]);
|
||||
|
||||
// Can't override super methods
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() { new B().bar(); }
|
||||
class A {
|
||||
mname() {}
|
||||
|
@ -1365,16 +1354,14 @@ testCantAssignMethods() {
|
|||
super.mname = () => 6;
|
||||
}
|
||||
}
|
||||
''',
|
||||
[
|
||||
MessageKind.ASSIGNING_METHOD_IN_SUPER,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.UNDEFINED_SETTER
|
||||
]);
|
||||
''', [
|
||||
MessageKind.ASSIGNING_METHOD_IN_SUPER,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.UNDEFINED_SETTER
|
||||
]);
|
||||
|
||||
// But index operators should be OK
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() { new B().bar(); }
|
||||
class B {
|
||||
operator[]=(x, y) {}
|
||||
|
@ -1382,10 +1369,8 @@ testCantAssignMethods() {
|
|||
this[1] = 3; // This is OK
|
||||
}
|
||||
}
|
||||
''',
|
||||
[]);
|
||||
checkWarningOn(
|
||||
'''
|
||||
''', []);
|
||||
checkWarningOn('''
|
||||
main() { new B().bar(); }
|
||||
class A {
|
||||
operator[]=(x, y) {}
|
||||
|
@ -1395,67 +1380,53 @@ testCantAssignMethods() {
|
|||
super[1] = 3; // This is OK
|
||||
}
|
||||
}
|
||||
''',
|
||||
[]);
|
||||
''', []);
|
||||
}
|
||||
|
||||
testCantAssignFinalAndConsts() {
|
||||
// Can't write final or const locals.
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() {
|
||||
final x = 1;
|
||||
x = 2;
|
||||
}
|
||||
''',
|
||||
[MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
checkWarningOn(
|
||||
'''
|
||||
''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
checkWarningOn('''
|
||||
main() {
|
||||
const x = 1;
|
||||
x = 2;
|
||||
}
|
||||
''',
|
||||
[MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
checkWarningOn(
|
||||
'''
|
||||
''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
checkWarningOn('''
|
||||
final x = 1;
|
||||
main() { x = 3; }
|
||||
''',
|
||||
[MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
const x = 1;
|
||||
main() { x = 3; }
|
||||
''',
|
||||
[MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
|
||||
|
||||
// Detect assignments to final fields:
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() => new B().m();
|
||||
class B {
|
||||
final x = 1;
|
||||
m() { x = 2; }
|
||||
}
|
||||
''',
|
||||
[MessageKind.UNDEFINED_SETTER]);
|
||||
''', [MessageKind.UNDEFINED_SETTER]);
|
||||
|
||||
// ... even if 'this' is explicit:
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() => new B().m();
|
||||
class B {
|
||||
final x = 1;
|
||||
m() { this.x = 2; }
|
||||
}
|
||||
''',
|
||||
[MessageKind.UNDEFINED_SETTER]);
|
||||
''', [MessageKind.UNDEFINED_SETTER]);
|
||||
|
||||
// ... and in super class:
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() => new B().m();
|
||||
class A {
|
||||
final x = 1;
|
||||
|
@ -1463,16 +1434,14 @@ testCantAssignFinalAndConsts() {
|
|||
class B extends A {
|
||||
m() { super.x = 2; }
|
||||
}
|
||||
''',
|
||||
[
|
||||
MessageKind.ASSIGNING_FINAL_FIELD_IN_SUPER,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.UNDEFINED_SETTER
|
||||
]);
|
||||
''', [
|
||||
MessageKind.ASSIGNING_FINAL_FIELD_IN_SUPER,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.UNDEFINED_SETTER
|
||||
]);
|
||||
|
||||
// But non-final fields are OK:
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() => new B().m();
|
||||
class A {
|
||||
int x = 1;
|
||||
|
@ -1480,12 +1449,10 @@ testCantAssignFinalAndConsts() {
|
|||
class B extends A {
|
||||
m() { super.x = 2; }
|
||||
}
|
||||
''',
|
||||
[]);
|
||||
''', []);
|
||||
|
||||
// Check getter without setter.
|
||||
checkWarningOn(
|
||||
'''
|
||||
checkWarningOn('''
|
||||
main() => new B().m();
|
||||
class A {
|
||||
get x => 1;
|
||||
|
@ -1493,12 +1460,11 @@ testCantAssignFinalAndConsts() {
|
|||
class B extends A {
|
||||
m() { super.x = 2; }
|
||||
}
|
||||
''',
|
||||
[
|
||||
MessageKind.UNDEFINED_SUPER_SETTER,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.UNDEFINED_SETTER
|
||||
]);
|
||||
''', [
|
||||
MessageKind.UNDEFINED_SUPER_SETTER,
|
||||
// TODO(johnniwinther): Avoid duplicate warnings.
|
||||
MessageKind.UNDEFINED_SETTER
|
||||
]);
|
||||
}
|
||||
|
||||
/// Helper to test that [script] produces all the given [warnings].
|
||||
|
@ -1541,29 +1507,22 @@ testAwaitHint() {
|
|||
check('main() { await -3; }', functionName: 'main');
|
||||
check('main() { () => await -3; }');
|
||||
check('foo() => await -3; main() => foo();', functionName: 'foo');
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
class A {
|
||||
m() => await - 3;
|
||||
}
|
||||
main() => new A().m();
|
||||
''',
|
||||
className: 'A',
|
||||
functionName: 'm');
|
||||
check(
|
||||
'''
|
||||
''', className: 'A', functionName: 'm');
|
||||
check('''
|
||||
class A {
|
||||
static m() => await - 3;
|
||||
}
|
||||
main() => A.m();
|
||||
''',
|
||||
functionName: 'm');
|
||||
check(
|
||||
'''
|
||||
''', functionName: 'm');
|
||||
check('''
|
||||
class A {
|
||||
m() => () => await - 3;
|
||||
}
|
||||
main() => new A().m();
|
||||
''',
|
||||
className: 'A');
|
||||
''', className: 'A');
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -74,35 +74,30 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Static fields': const [
|
||||
// Static fields
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C { static var o; }
|
||||
m() => C.o;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
static var o;
|
||||
m() => o;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
static var o;
|
||||
m() => C.o;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
const Test.prefix('''
|
||||
class C {
|
||||
static var o;
|
||||
}
|
||||
''',
|
||||
'm() => p.C.o;',
|
||||
''', 'm() => p.C.o;',
|
||||
const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
|
@ -125,30 +120,24 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)'),
|
||||
],
|
||||
isDeferred: true),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {
|
||||
var o;
|
||||
}
|
||||
m() => C.o;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
const Test(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
const Test('''
|
||||
class C {
|
||||
var o;
|
||||
}
|
||||
m() { C.o = 42; }
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_SET, name: 'o', rhs: '42')),
|
||||
const Test(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_SET, name: 'o', rhs: '42')),
|
||||
const Test('''
|
||||
class C {
|
||||
C.o();
|
||||
}
|
||||
m() => C.o;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
''',
|
||||
|
@ -158,12 +147,10 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
receiver: 'p.C', name: 'o'),
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'C'),
|
||||
]),
|
||||
const Test.prefix(
|
||||
'''
|
||||
const Test.prefix('''
|
||||
class C {
|
||||
}
|
||||
''',
|
||||
'm() => p.C.o;',
|
||||
''', 'm() => p.C.o;',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
|
@ -187,12 +174,10 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o'),
|
||||
],
|
||||
isDeferred: true),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {}
|
||||
m() => C.this;
|
||||
''',
|
||||
null),
|
||||
''', null),
|
||||
const Test(
|
||||
'''
|
||||
class C {
|
||||
|
@ -361,37 +346,32 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Static properties': const [
|
||||
// Static properties
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {
|
||||
static get o => null;
|
||||
}
|
||||
m() => C.o;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
static get o => null;
|
||||
m() => o;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
static get o => null;
|
||||
m() => C.o;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
const Test.prefix('''
|
||||
class C {
|
||||
static get o => null;
|
||||
}
|
||||
''',
|
||||
'm() => p.C.o;',
|
||||
''', 'm() => p.C.o;',
|
||||
const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
|
||||
const Test(
|
||||
'''
|
||||
|
@ -427,16 +407,14 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
'm() { p.C.o = 42; }',
|
||||
const Visit(VisitKind.VISIT_STATIC_GETTER_SET,
|
||||
element: 'getter(C#o)', rhs: '42')),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {
|
||||
static set o(_) {}
|
||||
}
|
||||
m() => C.o;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
static set o(_) {}
|
||||
m() => o;
|
||||
|
@ -444,21 +422,18 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
|
||||
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
static set o(_) {}
|
||||
m() => C.o;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
const Test.prefix('''
|
||||
class C {
|
||||
static set o(_) {}
|
||||
}
|
||||
''',
|
||||
'm() => p.C.o;',
|
||||
''', 'm() => p.C.o;',
|
||||
const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
|
||||
const Test(
|
||||
'''
|
||||
|
@ -677,17 +652,14 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Top level fields': const [
|
||||
// Top level fields
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
var o;
|
||||
m() => o;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, element: 'field(o)')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
const Test.prefix('''
|
||||
var o;
|
||||
''',
|
||||
'm() => p.o;',
|
||||
''', 'm() => p.o;',
|
||||
const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, element: 'field(o)')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
|
@ -699,10 +671,8 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, element: 'field(o)'),
|
||||
],
|
||||
isDeferred: true),
|
||||
const Test.prefix(
|
||||
'''
|
||||
''',
|
||||
'm() => p.o;',
|
||||
const Test.prefix('''
|
||||
''', 'm() => p.o;',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
const Test.prefix(
|
||||
'''
|
||||
|
@ -787,16 +757,12 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
'm() { p(null, 42); }',
|
||||
const Visit(VisitKind.ERROR_INVALID_INVOKE,
|
||||
error: MessageKind.PREFIX_AS_EXPRESSION, arguments: '(null,42)')),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => o;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
const Test(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
|
||||
const Test('''
|
||||
m() { o = 42; }
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_SET, name: 'o', rhs: '42')),
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_SET, name: 'o', rhs: '42')),
|
||||
],
|
||||
'Top level properties': const [
|
||||
// Top level properties
|
||||
|
@ -993,21 +959,17 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'This access': const [
|
||||
// This access
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
m() => this;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_GET)),
|
||||
const Test.clazz(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_THIS_GET)),
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
call(a, b) {}
|
||||
m() { this(null, 42); }
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_INVOKE, arguments: '(null,42)')),
|
||||
''', const Visit(VisitKind.VISIT_THIS_INVOKE, arguments: '(null,42)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
class C {
|
||||
|
@ -1020,30 +982,24 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'This properties': const [
|
||||
// This properties
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
var foo;
|
||||
m() => foo;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
var foo;
|
||||
m() => this.foo;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
get foo => null;
|
||||
m() => foo;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
class C {
|
||||
|
@ -1053,40 +1009,34 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.ERROR_INVALID_GET,
|
||||
error: MessageKind.NO_THIS_AVAILABLE)),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
get foo => null;
|
||||
m() => this.foo;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
var foo;
|
||||
m() { foo = 42; }
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: 'foo', rhs: '42')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
var foo;
|
||||
m() { this.foo = 42; }
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: 'foo', rhs: '42')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
set foo(_) {}
|
||||
m() { foo = 42; }
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: 'foo', rhs: '42')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class C {
|
||||
set foo(_) {}
|
||||
m() { this.foo = 42; }
|
||||
|
@ -1123,8 +1073,7 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Super fields': const [
|
||||
// Super fields
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
var o;
|
||||
}
|
||||
|
@ -1166,29 +1115,24 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.VISIT_SUPER_FIELD_INVOKE,
|
||||
element: 'field(B#o)', arguments: '(null,42)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
}
|
||||
class C extends B {
|
||||
m() => super.o;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GET)),
|
||||
const Test.clazz(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GET)),
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
}
|
||||
class C extends B {
|
||||
m() => super.o = 42;
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SET, rhs: '42')),
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SET, rhs: '42')),
|
||||
],
|
||||
'Super properties': const [
|
||||
// Super properties
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
get o => null;
|
||||
}
|
||||
|
@ -1197,8 +1141,7 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_SUPER_GETTER_GET, element: 'getter(B#o)')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
set o(_) {}
|
||||
}
|
||||
|
@ -1318,8 +1261,7 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Class type literals': const [
|
||||
// Class type literals
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {}
|
||||
m() => C;
|
||||
''',
|
||||
|
@ -1366,21 +1308,18 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_POSTFIX,
|
||||
constant: 'C', operator: '--')),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {}
|
||||
m() => (C).hashCode;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET,
|
||||
receiver: '(C)', name: 'hashCode'),
|
||||
const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_GET, constant: 'C'),
|
||||
]),
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET,
|
||||
receiver: '(C)', name: 'hashCode'),
|
||||
const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_GET, constant: 'C'),
|
||||
]),
|
||||
],
|
||||
'Typedef type literals': const [
|
||||
// Typedef type literals
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
typedef F();
|
||||
m() => F;
|
||||
''',
|
||||
|
@ -1594,46 +1533,38 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Logical and': const [
|
||||
// Logical and
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => true && false;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_LOGICAL_AND, left: 'true', right: 'false')),
|
||||
],
|
||||
'Logical or': const [
|
||||
// Logical or
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => true || false;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_LOGICAL_OR, left: 'true', right: 'false')),
|
||||
],
|
||||
'Is test': const [
|
||||
// Is test
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {}
|
||||
m() => 0 is C;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_IS, expression: '0', type: 'C')),
|
||||
''', const Visit(VisitKind.VISIT_IS, expression: '0', type: 'C')),
|
||||
],
|
||||
'Is not test': const [
|
||||
// Is not test
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {}
|
||||
m() => 0 is! C;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_IS_NOT, expression: '0', type: 'C')),
|
||||
''', const Visit(VisitKind.VISIT_IS_NOT, expression: '0', type: 'C')),
|
||||
],
|
||||
'As test': const [
|
||||
// As test
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
class C {}
|
||||
m() => 0 as C;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_AS, expression: '0', type: 'C')),
|
||||
''', const Visit(VisitKind.VISIT_AS, expression: '0', type: 'C')),
|
||||
],
|
||||
'Binary operators': const [
|
||||
// Binary operators
|
||||
|
@ -1773,11 +1704,9 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Index': const [
|
||||
// Index
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => 2[3];
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_INDEX, receiver: '2', index: '3')),
|
||||
''', const Visit(VisitKind.VISIT_INDEX, receiver: '2', index: '3')),
|
||||
const Test(
|
||||
'''
|
||||
m() => --2[3];
|
||||
|
@ -1801,15 +1730,13 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.VISIT_SUPER_INDEX,
|
||||
element: 'function(B#[])', index: '42')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
}
|
||||
class C extends B {
|
||||
m() => super[42];
|
||||
}
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX, index: '42')),
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX, index: '42')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
class B {
|
||||
|
@ -1999,11 +1926,9 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Equals': const [
|
||||
// Equals
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => 2 == 3;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_EQUALS, left: '2', right: '3')),
|
||||
''', const Visit(VisitKind.VISIT_EQUALS, left: '2', right: '3')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
class B {
|
||||
|
@ -2029,11 +1954,9 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Not equals': const [
|
||||
// Not equals
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => 2 != 3;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_NOT_EQUALS, left: '2', right: '3')),
|
||||
''', const Visit(VisitKind.VISIT_NOT_EQUALS, left: '2', right: '3')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
class B {
|
||||
|
@ -2059,13 +1982,11 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Unary expression': const [
|
||||
// Unary expression
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => -false;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNARY, expression: 'false', operator: '-')),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => ~false;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNARY, expression: 'false', operator: '~')),
|
||||
|
@ -2080,8 +2001,7 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.VISIT_SUPER_UNARY,
|
||||
element: 'function(B#unary-)', operator: '-')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
}
|
||||
class C extends B {
|
||||
|
@ -2111,13 +2031,10 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.ERROR_INVALID_UNARY,
|
||||
error: MessageKind.NO_SUPER_IN_STATIC, operator: '-')),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => !0;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_NOT, expression: '0')),
|
||||
const Test(
|
||||
'''
|
||||
''', const Visit(VisitKind.VISIT_NOT, expression: '0')),
|
||||
const Test('''
|
||||
m() => +false;
|
||||
''',
|
||||
// TODO(johnniwinther): Should this be an
|
||||
|
@ -2168,15 +2085,13 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Compound assignment': const [
|
||||
// Compound assignment
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m(a) => a.b += 42;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_COMPOUND,
|
||||
receiver: 'a', name: 'b', operator: '+=', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_COMPOUND,
|
||||
receiver: 'a', name: 'b', operator: '+=', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
m(a) => a += 42;
|
||||
|
@ -2718,15 +2633,13 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
],
|
||||
'Prefix expression': const [
|
||||
// Prefix expression
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m(a) => --a.b;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_PREFIX,
|
||||
receiver: 'a', name: 'b', operator: '--'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_PREFIX,
|
||||
receiver: 'a', name: 'b', operator: '--'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
m(a) => ++a;
|
||||
|
@ -2985,8 +2898,7 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.VISIT_SUPER_METHOD_PREFIX,
|
||||
element: 'function(B#a)', operator: '++')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
}
|
||||
class C extends B {
|
||||
|
@ -3089,23 +3001,19 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
const Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_PREFIX,
|
||||
element: 'field(a)', operator: '++')),
|
||||
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => ++unresolved;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_PREFIX, operator: '++')),
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_PREFIX, operator: '++')),
|
||||
],
|
||||
'Postfix expression': const [
|
||||
// Postfix expression
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m(a) => a.b--;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_POSTFIX,
|
||||
receiver: 'a', name: 'b', operator: '--'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_POSTFIX,
|
||||
receiver: 'a', name: 'b', operator: '--'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
m(a) => a++;
|
||||
|
@ -3364,8 +3272,7 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
''',
|
||||
const Visit(VisitKind.VISIT_SUPER_METHOD_POSTFIX,
|
||||
element: 'function(B#a)', operator: '++')),
|
||||
const Test.clazz(
|
||||
'''
|
||||
const Test.clazz('''
|
||||
class B {
|
||||
}
|
||||
class C extends B {
|
||||
|
@ -3468,11 +3375,9 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
const Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_POSTFIX,
|
||||
element: 'field(a)', operator: '++')),
|
||||
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m() => unresolved++;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_UNRESOLVED_POSTFIX, operator: '++')),
|
||||
''', const Visit(VisitKind.VISIT_UNRESOLVED_POSTFIX, operator: '++')),
|
||||
],
|
||||
'Constructor invocations': const [
|
||||
const Test(
|
||||
|
@ -3760,88 +3665,71 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
selector: 'CallStructure(arity=2)')),
|
||||
],
|
||||
'If not null expressions': const [
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m(a) => a?.b;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET,
|
||||
receiver: 'a', name: 'b'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET,
|
||||
receiver: 'a', name: 'b'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test('''
|
||||
class C {
|
||||
static var b;
|
||||
}
|
||||
m(a) => C?.b;
|
||||
''',
|
||||
const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#b)')),
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m(a) => a?.b = 42;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET,
|
||||
receiver: 'a', name: 'b', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET,
|
||||
receiver: 'a', name: 'b', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test('''
|
||||
m(a) => a?.b(42, true);
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_INVOKE,
|
||||
receiver: 'a',
|
||||
arguments: '(42,true)',
|
||||
selector: 'Selector(call, b, arity=2)'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_INVOKE,
|
||||
receiver: 'a',
|
||||
arguments: '(42,true)',
|
||||
selector: 'Selector(call, b, arity=2)'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test('''
|
||||
m(a) => ++a?.b;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_PREFIX,
|
||||
receiver: 'a', name: 'b', operator: '++'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_PREFIX,
|
||||
receiver: 'a', name: 'b', operator: '++'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test('''
|
||||
m(a) => a?.b--;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_POSTFIX,
|
||||
receiver: 'a', name: 'b', operator: '--'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_POSTFIX,
|
||||
receiver: 'a', name: 'b', operator: '--'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test('''
|
||||
m(a) => a?.b *= 42;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_COMPOUND,
|
||||
receiver: 'a', name: 'b', operator: '*=', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_COMPOUND,
|
||||
receiver: 'a', name: 'b', operator: '*=', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test('''
|
||||
m(a) => a?.b ??= 42;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET_IF_NULL,
|
||||
receiver: 'a', name: 'b', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET_IF_NULL,
|
||||
receiver: 'a', name: 'b', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
]),
|
||||
const Test('''
|
||||
m(a, b) => a ?? b;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_IF_NULL, left: 'a', right: 'b'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#b)'),
|
||||
]),
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_IF_NULL, left: 'a', right: 'b'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#b)'),
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
m(a) => a ??= 42;
|
||||
|
@ -3857,15 +3745,13 @@ const Map<String, List<Test>> SEND_TESTS = const {
|
|||
error: MessageKind.PREFIX_AS_EXPRESSION)),
|
||||
],
|
||||
'Set if null': const [
|
||||
const Test(
|
||||
'''
|
||||
const Test('''
|
||||
m(a) => a.b ??= 42;
|
||||
''',
|
||||
const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_SET_IF_NULL,
|
||||
receiver: 'a', name: 'b', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
''', const [
|
||||
const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_SET_IF_NULL,
|
||||
receiver: 'a', name: 'b', rhs: '42'),
|
||||
const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
|
||||
]),
|
||||
const Test(
|
||||
'''
|
||||
m(a) => a ??= 42;
|
||||
|
|
|
@ -148,9 +148,7 @@ ${jsTraceHtml}
|
|||
|
||||
/// Outputs [html] with customized [css] in [uri].
|
||||
void outputInTemplate(Uri uri, String html, String css) {
|
||||
output(
|
||||
uri,
|
||||
'''
|
||||
output(uri, '''
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
|
|
|
@ -28,8 +28,7 @@ void testRecordElement() {
|
|||
stats.recordElement('foo', 'b');
|
||||
stats.recordElement('bar', 'a', data: 'third-a-data');
|
||||
stats.recordElement('bar', 'c');
|
||||
},
|
||||
r'''
|
||||
}, r'''
|
||||
foo: 2
|
||||
value=a data=second-a-data
|
||||
b
|
||||
|
@ -46,8 +45,7 @@ void testRecordFrequency() {
|
|||
stats.recordFrequency('bar', 'b', 'first-b-data');
|
||||
stats.recordFrequency('foo', 'c');
|
||||
stats.recordFrequency('bar', 'b');
|
||||
},
|
||||
r'''
|
||||
}, r'''
|
||||
foo:
|
||||
a: 2
|
||||
first-a-data
|
||||
|
@ -70,8 +68,7 @@ void testRecordCounter() {
|
|||
stats.recordCounter('bar', 'd');
|
||||
stats.recordCounter('baz');
|
||||
stats.recordCounter('baz');
|
||||
},
|
||||
r'''
|
||||
}, r'''
|
||||
foo: 3
|
||||
count=2 example=a
|
||||
count=1 example=b
|
||||
|
|
|
@ -14,9 +14,7 @@ import 'package:compiler/src/universe/class_set.dart';
|
|||
import 'package:compiler/src/world.dart';
|
||||
|
||||
void main() {
|
||||
asyncTest(() => TypeEnvironment
|
||||
.create(
|
||||
r"""
|
||||
asyncTest(() => TypeEnvironment.create(r"""
|
||||
/// A
|
||||
/// / \
|
||||
/// B C
|
||||
|
@ -34,8 +32,7 @@ void main() {
|
|||
class G extends C {}
|
||||
class H implements C {}
|
||||
class I implements H {}
|
||||
""",
|
||||
mainSource: r"""
|
||||
""", mainSource: r"""
|
||||
main() {
|
||||
new A();
|
||||
new C();
|
||||
|
@ -44,9 +41,7 @@ void main() {
|
|||
new F();
|
||||
new G();
|
||||
}
|
||||
""",
|
||||
useMockCompiler: false)
|
||||
.then((env) {
|
||||
""", useMockCompiler: false).then((env) {
|
||||
ClosedWorld world = env.closedWorld;
|
||||
|
||||
ClassElement A = env.getElement("A");
|
||||
|
|
|
@ -179,16 +179,10 @@ class Class {
|
|||
foo.ensureResolved(compiler.resolution);
|
||||
FunctionElement method = foo.lookupLocalMember('forIn');
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (var e in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (String e in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
|
@ -198,36 +192,21 @@ class Class {
|
|||
for (int e in <String>[]) {}
|
||||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (int e in []) {}
|
||||
}""");
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (var e in new HasUntypedIterator()) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (String e in new HasUntypedIterator()) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (int e in new HasUntypedIterator()) {}
|
||||
}""");
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (var e in new HasIntIterator()) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
|
@ -237,10 +216,7 @@ class Class {
|
|||
for (String e in new HasIntIterator()) {}
|
||||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (int e in new HasIntIterator()) {}
|
||||
}""");
|
||||
|
||||
|
@ -266,10 +242,7 @@ class Class {
|
|||
}""",
|
||||
warnings: MessageKind.UNDEFINED_GETTER);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (var e in new HasCustomIntIterator()) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
|
@ -279,10 +252,7 @@ class Class {
|
|||
for (String e in new HasCustomIntIterator()) {}
|
||||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (int e in new HasCustomIntIterator()) {}
|
||||
}""");
|
||||
|
||||
|
@ -308,17 +278,11 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.UNDEFINED_GETTER);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
var localDyn;
|
||||
for (localDyn in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
String localString;
|
||||
for (localString in <String>[]) {}
|
||||
}""");
|
||||
|
@ -331,16 +295,10 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (topLevelDyn in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (topLevelString in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
|
@ -351,16 +309,10 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (instanceDyn in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (instanceString in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
|
@ -371,16 +323,10 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (staticDyn in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
for (staticString in <String>[]) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
|
@ -419,24 +365,15 @@ class Class {
|
|||
foo.ensureResolved(compiler.resolution);
|
||||
FunctionElement method = foo.lookupLocalMember('forIn');
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
var stream;
|
||||
await for (var e in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
var stream;
|
||||
await for (String e in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
var stream;
|
||||
await for (int e in stream) {}
|
||||
}""");
|
||||
|
@ -449,17 +386,11 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (var e in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (String e in stream) {}
|
||||
}""");
|
||||
|
@ -472,17 +403,11 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
CustomStream<String> stream;
|
||||
await for (var e in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
CustomStream<String> stream;
|
||||
await for (String e in stream) {}
|
||||
}""");
|
||||
|
@ -495,17 +420,11 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
StringStream stream;
|
||||
await for (var e in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
StringStream stream;
|
||||
await for (String e in stream) {}
|
||||
}""");
|
||||
|
@ -518,18 +437,12 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
var localDyn;
|
||||
await for (localDyn in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
String localString;
|
||||
await for (localString in stream) {}
|
||||
|
@ -544,17 +457,11 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (topLevelDyn in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (topLevelString in stream) {}
|
||||
}""");
|
||||
|
@ -567,17 +474,11 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (instanceDyn in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (instanceString in stream) {}
|
||||
}""");
|
||||
|
@ -590,17 +491,11 @@ class Class {
|
|||
}""",
|
||||
hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
||||
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (staticDyn in stream) {}
|
||||
}""");
|
||||
analyzeIn(
|
||||
compiler,
|
||||
method,
|
||||
"""{
|
||||
analyzeIn(compiler, method, """{
|
||||
Stream<String> stream;
|
||||
await for (staticString in stream) {}
|
||||
}""");
|
||||
|
@ -711,56 +606,42 @@ case Enum.B: break;
|
|||
case Enum.C: break;
|
||||
}""");
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
switch (Enum.A) {
|
||||
case Enum.B: break;
|
||||
case Enum.C: break;
|
||||
}""",
|
||||
warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}""", warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
switch (Enum.A) {
|
||||
case Enum.A: break;
|
||||
case Enum.C: break;
|
||||
}""",
|
||||
warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}""", warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
switch (Enum.A) {
|
||||
case Enum.A: break;
|
||||
case Enum.B: break;
|
||||
}""",
|
||||
warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}""", warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
switch (Enum.A) {
|
||||
case Enum.A: break;
|
||||
}""",
|
||||
warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}""", warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
switch (Enum.A) {
|
||||
case Enum.B: break;
|
||||
}""",
|
||||
warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}""", warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
switch (Enum.A) {
|
||||
case Enum.C: break;
|
||||
}""",
|
||||
warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}""", warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
|
||||
check(
|
||||
"""
|
||||
check("""
|
||||
switch (Enum.A) {
|
||||
}""",
|
||||
warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}""", warnings: MessageKind.MISSING_ENUM_CASES);
|
||||
}
|
||||
|
||||
testOperators(MockCompiler compiler) {
|
||||
|
@ -1664,11 +1545,9 @@ Future testFieldInitializers(MockCompiler compiler) {
|
|||
check("""class Class {
|
||||
int i = 0;
|
||||
}"""),
|
||||
check(
|
||||
"""class Class {
|
||||
check("""class Class {
|
||||
int i = '';
|
||||
}""",
|
||||
NOT_ASSIGNABLE),
|
||||
}""", NOT_ASSIGNABLE),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -1880,25 +1759,21 @@ Future testInitializers(MockCompiler compiler) {
|
|||
Class(int this.a);
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Class {
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(int this.a);
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
check(r'''class Class {
|
||||
var a;
|
||||
Class(int a) : this.a = a;
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Class {
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(int a) : this.a = a;
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
|
||||
// Check this-calls.
|
||||
check(r'''class Class {
|
||||
|
@ -1907,28 +1782,24 @@ Future testInitializers(MockCompiler compiler) {
|
|||
Class.named(int a) : this(a);
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Class {
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(this.a);
|
||||
Class.named(int a) : this(a);
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(var a) : this.a = a;
|
||||
Class.named(int a) : this(a);
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Class {
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(String a) : this.a = a;
|
||||
Class.named(int a) : this(a);
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
|
||||
// Check super-calls.
|
||||
check(r'''class Super {
|
||||
|
@ -1939,16 +1810,14 @@ Future testInitializers(MockCompiler compiler) {
|
|||
Class.named(int a) : super(a);
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Super {
|
||||
check(r'''class Super {
|
||||
String a;
|
||||
Super(this.a);
|
||||
}
|
||||
class Class extends Super {
|
||||
Class.named(int a) : super(a);
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
check(r'''class Super {
|
||||
String a;
|
||||
Super(var a) : this.a = a;
|
||||
|
@ -1957,16 +1826,14 @@ Future testInitializers(MockCompiler compiler) {
|
|||
Class.named(int a) : super(a);
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Super {
|
||||
check(r'''class Super {
|
||||
String a;
|
||||
Super(String a) : this.a = a;
|
||||
}
|
||||
class Class extends Super {
|
||||
Class.named(int a) : super(a);
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
|
||||
// Check super-calls involving generics.
|
||||
check(r'''class Super<T> {
|
||||
|
@ -1977,16 +1844,14 @@ Future testInitializers(MockCompiler compiler) {
|
|||
Class.named(int a) : super(a);
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Super<T> {
|
||||
check(r'''class Super<T> {
|
||||
T a;
|
||||
Super(this.a);
|
||||
}
|
||||
class Class extends Super<String> {
|
||||
Class.named(int a) : super(a);
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
check(r'''class Super<T> {
|
||||
T a;
|
||||
Super(var a) : this.a = a;
|
||||
|
@ -1995,16 +1860,14 @@ Future testInitializers(MockCompiler compiler) {
|
|||
Class.named(int a) : super(a);
|
||||
}
|
||||
'''),
|
||||
check(
|
||||
r'''class Super<T> {
|
||||
check(r'''class Super<T> {
|
||||
T a;
|
||||
Super(T a) : this.a = a;
|
||||
}
|
||||
class Class extends Super<String> {
|
||||
Class.named(int a) : super(a);
|
||||
}
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
|
||||
// Check instance creations.
|
||||
check(r'''class Class {
|
||||
|
@ -2013,28 +1876,24 @@ Future testInitializers(MockCompiler compiler) {
|
|||
}
|
||||
method(int a) => new Class(a);
|
||||
'''),
|
||||
check(
|
||||
r'''class Class {
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(this.a);
|
||||
}
|
||||
method(int a) => new Class(a);
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(var a) : this.a = a;
|
||||
}
|
||||
method(int a) => new Class(a);
|
||||
'''),
|
||||
check(
|
||||
r'''class Class {
|
||||
check(r'''class Class {
|
||||
String a;
|
||||
Class(String a) : this.a = a;
|
||||
}
|
||||
method(int a) => new Class(a);
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
|
||||
// Check instance creations involving generics.
|
||||
check(r'''class Class<T> {
|
||||
|
@ -2043,28 +1902,24 @@ Future testInitializers(MockCompiler compiler) {
|
|||
}
|
||||
method(int a) => new Class<String>(a);
|
||||
'''),
|
||||
check(
|
||||
r'''class Class<T> {
|
||||
check(r'''class Class<T> {
|
||||
T a;
|
||||
Class(this.a);
|
||||
}
|
||||
method(int a) => new Class<String>(a);
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
check(r'''class Class<T> {
|
||||
T a;
|
||||
Class(var a) : this.a = a;
|
||||
}
|
||||
method(int a) => new Class<String>(a);
|
||||
'''),
|
||||
check(
|
||||
r'''class Class<T> {
|
||||
check(r'''class Class<T> {
|
||||
T a;
|
||||
Class(String a) : this.a = a;
|
||||
}
|
||||
method(int a) => new Class<String>(a);
|
||||
''',
|
||||
NOT_ASSIGNABLE),
|
||||
''', NOT_ASSIGNABLE),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -2191,8 +2046,7 @@ testTypePromotionHints(MockCompiler compiler) {
|
|||
warnings: warnings, hints: hints, infos: infos);
|
||||
}
|
||||
|
||||
check(
|
||||
r'''
|
||||
check(r'''
|
||||
A a = new B();
|
||||
if (a is C) {
|
||||
var x = a.c;
|
||||
|
@ -2201,8 +2055,7 @@ testTypePromotionHints(MockCompiler compiler) {
|
|||
hints: [MessageKind.NOT_MORE_SPECIFIC_SUBTYPE],
|
||||
infos: []);
|
||||
|
||||
check(
|
||||
r'''
|
||||
check(r'''
|
||||
A a = new B();
|
||||
if (a is C) {
|
||||
var x = '${a.c}${a.c}';
|
||||
|
@ -2211,8 +2064,7 @@ testTypePromotionHints(MockCompiler compiler) {
|
|||
hints: [MessageKind.NOT_MORE_SPECIFIC_SUBTYPE],
|
||||
infos: []);
|
||||
|
||||
check(
|
||||
r'''
|
||||
check(r'''
|
||||
A a = new B();
|
||||
if (a is C) {
|
||||
var x = '${a.d}${a.d}'; // Type promotion wouldn't help.
|
||||
|
@ -2221,53 +2073,40 @@ testTypePromotionHints(MockCompiler compiler) {
|
|||
hints: [],
|
||||
infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
D<int> d = new E();
|
||||
if (d is E) { // Suggest E<int>.
|
||||
var x = d.e;
|
||||
}''',
|
||||
warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
],
|
||||
hints: [
|
||||
checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
|
||||
{'shownTypeSuggestion': 'E<int>'})
|
||||
],
|
||||
infos: []);
|
||||
}''', warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
], hints: [
|
||||
checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
|
||||
{'shownTypeSuggestion': 'E<int>'})
|
||||
], infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
D<int> d = new F();
|
||||
if (d is F) { // Suggest F<int, dynamic>.
|
||||
var x = d.f;
|
||||
}''',
|
||||
warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
],
|
||||
hints: [
|
||||
checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
|
||||
{'shownTypeSuggestion': 'F<int, dynamic>'})
|
||||
],
|
||||
infos: []);
|
||||
}''', warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
], hints: [
|
||||
checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
|
||||
{'shownTypeSuggestion': 'F<int, dynamic>'})
|
||||
], infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
D<int> d = new G();
|
||||
if (d is G) { // Suggest G<int>.
|
||||
var x = d.f;
|
||||
}''',
|
||||
warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
],
|
||||
hints: [
|
||||
checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
|
||||
{'shownTypeSuggestion': 'G<int>'})
|
||||
],
|
||||
infos: []);
|
||||
}''', warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
], hints: [
|
||||
checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
|
||||
{'shownTypeSuggestion': 'G<int>'})
|
||||
], infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
F<double, int> f = new G();
|
||||
if (f is G) { // Cannot suggest a more specific type.
|
||||
var x = f.g;
|
||||
|
@ -2276,18 +2115,14 @@ testTypePromotionHints(MockCompiler compiler) {
|
|||
hints: [MessageKind.NOT_MORE_SPECIFIC],
|
||||
infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
D<int> d = new E();
|
||||
if (d is E) {
|
||||
var x = d.f; // Type promotion wouldn't help.
|
||||
}''',
|
||||
warnings: [MessageKind.UNDEFINED_GETTER],
|
||||
hints: [],
|
||||
infos: []);
|
||||
warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
a = null;
|
||||
|
@ -2297,19 +2132,15 @@ testTypePromotionHints(MockCompiler compiler) {
|
|||
hints: [MessageKind.POTENTIAL_MUTATION],
|
||||
infos: [MessageKind.POTENTIAL_MUTATION_HERE]);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
a = null;
|
||||
var x = a.c; // Type promotion wouldn't help.
|
||||
}''',
|
||||
warnings: [MessageKind.UNDEFINED_GETTER],
|
||||
hints: [],
|
||||
infos: []);
|
||||
warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
A a = new B();
|
||||
local() { a = new A(); }
|
||||
if (a is B) {
|
||||
|
@ -2319,47 +2150,37 @@ testTypePromotionHints(MockCompiler compiler) {
|
|||
hints: [MessageKind.POTENTIAL_MUTATION_IN_CLOSURE],
|
||||
infos: [MessageKind.POTENTIAL_MUTATION_IN_CLOSURE_HERE]);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
A a = new B();
|
||||
local() { a = new A(); }
|
||||
if (a is B) {
|
||||
var x = a.c; // Type promotion wouldn't help.
|
||||
}''',
|
||||
warnings: [MessageKind.UNDEFINED_GETTER],
|
||||
hints: [],
|
||||
infos: []);
|
||||
warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
var x = () => a;
|
||||
var y = a.b;
|
||||
}
|
||||
a = new A();''',
|
||||
warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
],
|
||||
hints: [
|
||||
MessageKind.ACCESSED_IN_CLOSURE
|
||||
],
|
||||
infos: [
|
||||
MessageKind.ACCESSED_IN_CLOSURE_HERE,
|
||||
MessageKind.POTENTIAL_MUTATION_HERE
|
||||
]);
|
||||
a = new A();''', warnings: [
|
||||
MessageKind.UNDEFINED_GETTER
|
||||
], hints: [
|
||||
MessageKind.ACCESSED_IN_CLOSURE
|
||||
], infos: [
|
||||
MessageKind.ACCESSED_IN_CLOSURE_HERE,
|
||||
MessageKind.POTENTIAL_MUTATION_HERE
|
||||
]);
|
||||
|
||||
check(
|
||||
'''
|
||||
check('''
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
var x = () => a;
|
||||
var y = a.c; // Type promotion wouldn't help.
|
||||
}
|
||||
a = new A();''',
|
||||
warnings: [MessageKind.UNDEFINED_GETTER],
|
||||
hints: [],
|
||||
infos: []);
|
||||
warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
|
||||
}
|
||||
|
||||
void testCascade(MockCompiler compiler) {
|
||||
|
|
|
@ -53,8 +53,7 @@ test(compiler, String name1, String name2, {bool expect}) {
|
|||
|
||||
void main() {
|
||||
var uri = new Uri(scheme: 'source');
|
||||
var compiler = compilerFor(
|
||||
r"""
|
||||
var compiler = compilerFor(r"""
|
||||
typedef int Typedef1<X,Y>(String s1);
|
||||
typedef void Typedef2<Z>(T t1, S s1);
|
||||
|
||||
|
@ -86,10 +85,7 @@ void main() {
|
|||
}
|
||||
|
||||
void main() {}
|
||||
""",
|
||||
uri,
|
||||
analyzeAll: true,
|
||||
analyzeOnly: true);
|
||||
""", uri, analyzeAll: true, analyzeOnly: true);
|
||||
asyncTest(() => compiler.run(uri).then((_) {
|
||||
test(compiler, "void1", "void2", expect: true);
|
||||
test(compiler, "int1", "int2", expect: true);
|
||||
|
|
|
@ -86,15 +86,13 @@ checkMasks(ClosedWorld closedWorld, List<ClassElement> allClasses,
|
|||
}
|
||||
|
||||
Future testUnionTypeMaskFlatten() async {
|
||||
TypeEnvironment env = await TypeEnvironment.create(
|
||||
r"""
|
||||
TypeEnvironment env = await TypeEnvironment.create(r"""
|
||||
class A {}
|
||||
class B {}
|
||||
class C extends A {}
|
||||
class D implements A {}
|
||||
class E extends B implements A {}
|
||||
""",
|
||||
mainSource: r"""
|
||||
""", mainSource: r"""
|
||||
main() {
|
||||
new A();
|
||||
new B();
|
||||
|
@ -102,8 +100,7 @@ Future testUnionTypeMaskFlatten() async {
|
|||
new D();
|
||||
new E();
|
||||
}
|
||||
""",
|
||||
useMockCompiler: false);
|
||||
""", useMockCompiler: false);
|
||||
|
||||
ClosedWorld closedWorld = env.closedWorld;
|
||||
|
||||
|
|
|
@ -164,20 +164,17 @@ void main() {
|
|||
}
|
||||
|
||||
Future test6() {
|
||||
return test(
|
||||
r"""
|
||||
return test(r"""
|
||||
class A<T extends num> {}
|
||||
|
||||
void main() {
|
||||
new A<String>();
|
||||
}
|
||||
""",
|
||||
warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND);
|
||||
""", warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND);
|
||||
}
|
||||
|
||||
Future test7() {
|
||||
return test(
|
||||
r"""
|
||||
return test(r"""
|
||||
class A<T extends num> {}
|
||||
class B<T> extends A<T> {} // Warning produced here.
|
||||
|
||||
|
@ -185,8 +182,7 @@ void main() {
|
|||
new B(); // No warning produced here.
|
||||
new B<String>(); // No warning produced here.
|
||||
}
|
||||
""",
|
||||
warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND);
|
||||
""", warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND);
|
||||
}
|
||||
|
||||
Future test8() {
|
||||
|
@ -217,8 +213,7 @@ void main() {
|
|||
}
|
||||
|
||||
Future test9() {
|
||||
return test(
|
||||
r"""
|
||||
return test(r"""
|
||||
class B<T extends B<T>> {}
|
||||
class C<T extends B<T>> extends B<T> {}
|
||||
class D<T extends C<T>> extends C<T> {}
|
||||
|
@ -229,11 +224,10 @@ void main() {
|
|||
new D<B<F>>(); // Warning: B<F> is not a subtype of C<T>.
|
||||
new E<D<F>>(); // Warning: E<F> is not a subtype of E<T>.
|
||||
}
|
||||
""",
|
||||
warnings: [
|
||||
MessageKind.INVALID_TYPE_VARIABLE_BOUND,
|
||||
MessageKind.INVALID_TYPE_VARIABLE_BOUND
|
||||
]);
|
||||
""", warnings: [
|
||||
MessageKind.INVALID_TYPE_VARIABLE_BOUND,
|
||||
MessageKind.INVALID_TYPE_VARIABLE_BOUND
|
||||
]);
|
||||
}
|
||||
|
||||
Future test10() {
|
||||
|
@ -254,8 +248,7 @@ main() {
|
|||
// TODO(het): The error is reported twice because both the Dart and JS constant
|
||||
// compilers are run on the const constructor, investigate why.
|
||||
Future test11() {
|
||||
return test(
|
||||
r"""
|
||||
return test(r"""
|
||||
class A {
|
||||
const A();
|
||||
}
|
||||
|
@ -269,8 +262,7 @@ class Test<T extends A> {
|
|||
main() {
|
||||
print(const Test<B>());
|
||||
}
|
||||
""",
|
||||
errors: [MessageKind.NOT_ASSIGNABLE, MessageKind.NOT_ASSIGNABLE]);
|
||||
""", errors: [MessageKind.NOT_ASSIGNABLE, MessageKind.NOT_ASSIGNABLE]);
|
||||
}
|
||||
|
||||
main() {
|
||||
|
|
|
@ -10,18 +10,15 @@ import 'type_test_helper.dart';
|
|||
|
||||
main() {
|
||||
asyncTest(() async {
|
||||
TypeEnvironment env = await TypeEnvironment.create(
|
||||
r"""
|
||||
TypeEnvironment env = await TypeEnvironment.create(r"""
|
||||
class A {}
|
||||
class B {}
|
||||
""",
|
||||
mainSource: r"""
|
||||
""", mainSource: r"""
|
||||
main() {
|
||||
new A();
|
||||
new B();
|
||||
}
|
||||
""",
|
||||
useMockCompiler: false);
|
||||
""", useMockCompiler: false);
|
||||
ClosedWorld world = env.closedWorld;
|
||||
FlatTypeMask mask1 = new FlatTypeMask.exact(env.getClass('A'));
|
||||
FlatTypeMask mask2 = new FlatTypeMask.exact(env.getClass('B'));
|
||||
|
|
|
@ -24,8 +24,7 @@ void main() {
|
|||
}
|
||||
|
||||
testClassSets() async {
|
||||
var env = await TypeEnvironment.create(
|
||||
r"""
|
||||
var env = await TypeEnvironment.create(r"""
|
||||
class A implements X {}
|
||||
class B {}
|
||||
class C_Super extends A {}
|
||||
|
@ -35,8 +34,7 @@ testClassSets() async {
|
|||
class F extends Object with A implements B {}
|
||||
class G extends Object with A, B {}
|
||||
class X {}
|
||||
""",
|
||||
mainSource: r"""
|
||||
""", mainSource: r"""
|
||||
import 'dart:html' as html;
|
||||
main() {
|
||||
new A();
|
||||
|
@ -49,8 +47,7 @@ testClassSets() async {
|
|||
html.window;
|
||||
new html.Worker('');
|
||||
}
|
||||
""",
|
||||
useMockCompiler: false);
|
||||
""", useMockCompiler: false);
|
||||
ClosedWorld closedWorld = env.closedWorld;
|
||||
|
||||
ClassElement Object_ = env.getElement("Object");
|
||||
|
@ -182,8 +179,7 @@ testClassSets() async {
|
|||
}
|
||||
|
||||
testProperties() async {
|
||||
var env = await TypeEnvironment.create(
|
||||
r"""
|
||||
var env = await TypeEnvironment.create(r"""
|
||||
class A {}
|
||||
class A1 extends A {}
|
||||
class A2 implements A {}
|
||||
|
@ -225,8 +221,7 @@ testProperties() async {
|
|||
class H2 extends H1 {}
|
||||
class H3 extends H2 implements H {}
|
||||
class H4 extends H2 with H {}
|
||||
""",
|
||||
mainSource: r"""
|
||||
""", mainSource: r"""
|
||||
main() {
|
||||
new B();
|
||||
new C1();
|
||||
|
@ -238,8 +233,7 @@ testProperties() async {
|
|||
new G3();
|
||||
new H4();
|
||||
}
|
||||
""",
|
||||
useMockCompiler: false);
|
||||
""", useMockCompiler: false);
|
||||
ClosedWorld closedWorld = env.closedWorld;
|
||||
|
||||
check(String name, {bool hasStrictSubtype, bool hasOnlySubclasses}) {
|
||||
|
|
Loading…
Reference in a new issue