Migrate language_2/identifier to NNBD.

Change-Id: If2883e339658bf6a8bb34a9aead689fc7697df4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148146
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
This commit is contained in:
Robert Nystrom
2020-05-15 18:47:52 +00:00
committed by commit-bot@chromium.org
parent 516ad5ce1c
commit 1d87f8e384
25 changed files with 2144 additions and 6 deletions
@@ -0,0 +1,118 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Check that we can use pseudo keywords as names in function level code.
import "package:expect/expect.dart";
class PseudoKWTest {
static testMain() {
// This is a list of built-in identifiers from the Dart spec.
// It sanity checks that these pseudo-keywords are legal identifiers.
var abstract = 0; //# 01: ok
var as = 0;
var dynamic = 0;
var export = 0;
var external = 0; //# 01: ok
var factory = 0;
var get = 0;
var interface = 0;
var implements = 0;
var import = 0;
var library = 0;
var mixin = 0;
var operator = 0;
var part = 0;
var set = 0;
var static = 0; //# 01: ok
var typedef = 0;
// "native" is a per-implementation extension that is not a part of the
// Dart language. While it is not an official built-in identifier, it
// is useful to ensure that it remains a legal identifier.
var native = 0;
// The code below adds a few additional variants of usage without any
// attempt at complete coverage.
{
void factory(set) {
return; //# 01: ok
}
}
get:
while (import > 0) {
break get;
}
return
static + //# 01: ok
library * operator;
}
}
typedef(x) => "typedef $x"; //# 01: ok
static(abstract) { //# 01: ok
return abstract == true; //# 01: ok
} //# 01: ok
class A {
var typedef = 0;
final operator = "smooth";
set(x) {
typedef = x;
}
get() => typedef - 5;
static static() { //# 01: ok
return 1; //# 01: ok
} //# 01: ok
static check() {
var o = new A();
o.set(55);
Expect.equals(50, o.get());
static(); //# 01: ok
}
}
class B {
var set = 100;
get get => set;
set get(get) => set = (2 * get.get).toInt();
static() { //# 01: ok
var set = new B(); //# 01: ok
set.get = set; //# 01: ok
Expect.equals(200, set.get); //# 01: ok
} //# 01: ok
int operator() {
return 1;
}
}
class C {
static int operator = (5);
static var get;
static get set => 111;
static set set(set) {}
}
main() {
PseudoKWTest.testMain();
A.check();
new B().static(); //# 01: ok
Expect.equals(1, new B().operator());
Expect.equals(1, A.static()); //# 01: ok
typedef("T"); //# 01: ok
Expect.equals("typedef T", typedef("T")); //# 01: ok
static("true"); //# 01: ok
Expect.equals(false, static("true")); //# 01: ok
Expect.equals(5, C.operator);
Expect.equals(null, C.get);
C.set = 0;
Expect.equals(111, C.set);
}
@@ -0,0 +1,28 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Check that we cannot use a pseudo keyword at the class level code.
// Pseudo keywords are not allowed to be used as class names.
main() {}
@@ -0,0 +1,178 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Check that we cannot use a pseudo keyword at the class level code.
// Pseudo keywords are not allowed to be used as class names.
class abstract { }
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'abstract' as a name here.
class as { }
// ^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'as' as a name here.
class dynamic { }
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'dynamic' as a name here.
class export { }
// ^^^^^^
// [analyzer] SYNTACTIC_ERROR.DIRECTIVE_AFTER_DECLARATION
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] Directives must appear before any declarations.
// ^^^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'export'.
// [error line 19, column 14, length 0]
// [cfe] Expected ';' after this.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
// [cfe] Expected a String, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_STRING_LITERAL
// [cfe] Expected a declaration, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
class external { }
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'external' as a name here.
class factory { }
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'factory' as a name here.
class get { }
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_PARAMETERS
// [cfe] A function declaration needs an explicit list of parameters.
// ^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'get'.
class interface { }
// ^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'interface' as a name here.
class implements { }
// ^^^^^^^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'implements'.
// [error line 61, column 18, length 0]
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
// [cfe] Expected a type, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TYPE_NAME
class import { }
// ^^^^^^
// [analyzer] SYNTACTIC_ERROR.DIRECTIVE_AFTER_DECLARATION
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] Directives must appear before any declarations.
// ^^^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'import'.
// [error line 70, column 14, length 0]
// [cfe] Expected ';' after this.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
// [cfe] Expected a String, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_STRING_LITERAL
// [cfe] Expected a declaration, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
class mixin { }
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'mixin'.
// ^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got '{'.
class library { }
// ^^^^^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^^^^^
// [analyzer] SYNTACTIC_ERROR.LIBRARY_DIRECTIVE_NOT_FIRST
// [cfe] Expected an identifier, but got 'library'.
// ^^^^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] The library directive must appear before all other directives.
// ^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
// [cfe] Expected ';' after this.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected a declaration, but got '}'.
class operator { }
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'operator' as a name here.
class part { }
// ^^^^
// [analyzer] SYNTACTIC_ERROR.DIRECTIVE_AFTER_DECLARATION
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] Directives must appear before any declarations.
// ^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'part'.
// [error line 123, column 12, length 0]
// [analyzer] COMPILE_TIME_ERROR.PART_OF_NON_PART
// [cfe] Expected ';' after this.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
// [cfe] Expected a String, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_STRING_LITERAL
// [cfe] Expected a declaration, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
class set { }
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_PARAMETERS
// [cfe] A function declaration needs an explicit list of parameters.
// ^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'set'.
class static { }
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
// [cfe] Can't use 'static' as a name here.
class typedef { }
// ^^^^^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
// [cfe] A class declaration must have a body, even if it is empty.
// ^^^^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got 'typedef'.
// ^
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
// [cfe] Expected an identifier, but got '{'.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
// [cfe] A typedef needs an explicit list of parameters.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected ';' after this.
// ^
// [analyzer] SYNTACTIC_ERROR.MISSING_TYPEDEF_PARAMETERS
// [cfe] Expected a declaration, but got '}'.
main() {}
@@ -0,0 +1,62 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// From The Dart Programming Language Specification, section 16.33
// "Identifier Reference":
//
// "A built-in identifier is one of the identifiers produced by the
// production BUILT_IN_IDENTIFIER. It is a compile-time error if a
// built-in identifier is used as the declared name of a prefix, class,
// type parameter or type alias. It is a compile-time error to use a
// built-in identifier other than dynamic in a type annotation or type
// parameter."
//
// Observation: it is illegal to use a built-in identifier as a library
// prefix.
// Dart test for using a built-in identifier as a library prefix.
import "dart:core" // Fine unless imported with a built-in identifier as prefix.
deferred as abstract // //# deferred-abstract: compile-time error
deferred as as // //# deferred-as: compile-time error
deferred as covariant // //# deferred-covariant: compile-time error
deferred as deferred // //# deferred-deferred: compile-time error
deferred as dynamic // //# deferred-dynamic: compile-time error
deferred as export // //# deferred-export: compile-time error
deferred as external // //# deferred-external: compile-time error
deferred as factory // //# deferred-factory: compile-time error
deferred as get // //# deferred-get: compile-time error
deferred as implements // //# deferred-implements: compile-time error
deferred as import // //# deferred-import: compile-time error
deferred as interface // //# deferred-interface: compile-time error
deferred as library // //# deferred-library: compile-time error
deferred as mixin // //# deferred-mixin: compile-time error
deferred as operator // //# deferred-operator: compile-time error
deferred as part // //# deferred-part: compile-time error
deferred as set // //# deferred-set: compile-time error
deferred as static // //# deferred-static: compile-time error
deferred as typedef // //# deferred-typedef: compile-time error
as abstract // //# abstract: compile-time error
as as // //# as: compile-time error
as covariant // //# covariant: compile-time error
as deferred // //# deferred: compile-time error
as dynamic // //# dynamic: compile-time error
as export // //# export: compile-time error
as external // //# external: compile-time error
as factory // //# factory: compile-time error
as get // //# get: compile-time error
as implements // //# implements: compile-time error
as import // //# import: compile-time error
as interface // //# interface: compile-time error
as library // //# library: compile-time error
as mixin // //# mixin: compile-time error
as operator // //# operator: compile-time error
as part // //# part: compile-time error
as set // //# set: compile-time error
as static // //# static: compile-time error
as typedef // //# typedef: compile-time error
;
main() {
}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library async;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library await;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library hide;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library library;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library of;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library on;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library show;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library sync;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,11 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library yield;
class A {}
class B<T> {}
class C<T, S> {}
@@ -0,0 +1,129 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// From The Dart Programming Language Specification, section 16.33
// "Identifier Reference":
//
// "A built-in identifier is one of the identifiers produced by the
// production BUILT_IN_IDENTIFIER. It is a compile-time error if a
// built-in identifier is used as the declared name of a prefix, class,
// type parameter or type alias. It is a compile-time error to use a
// built-in identifier other than dynamic in a type annotation or type
// parameter."
//
// Observation: it is illegal to use a built-in identifier other than
// `dynamic` in a type annotation. A type annotation is not fully defined
// in the specification, so we assume this means that the grammar
// production "type" cannot be a built-in identifier, and it cannot contain
// a built-in identifier at a location where it must denote a type.
//
// Note that we have several ways to use built-in identifiers other than
// `dynamic` in other locations in a type, e.g., `Function(int set)`.
final // optional type before variable must not be a built-in identifier.
abstract // //# abstract: syntax error
as // //# as: syntax error
covariant // //# covariant: syntax error
deferred // //# deferred: syntax error
dynamic // //# dynamic: ok
export // //# export: syntax error
external // //# external: syntax error
factory // //# factory: syntax error
get // //# get: syntax error
implements // //# implements: syntax error
import // //# import: syntax error
interface // //# interface: syntax error
library // //# library: syntax error
mixin // //# mixin: syntax error
operator // //# operator: syntax error
part // //# part: syntax error
set // //# set: syntax error
static // //# static: syntax error
typedef // //# typedef: syntax error
abstract<int>? // //# abstract-gen: syntax error
as<int>? // //# as-gen: syntax error
covariant<int>? // //# covariant-gen: syntax error
deferred<int>? // //# deferred-gen: syntax error
dynamic<int>? // //# dynamic-gen: compile-time error
export<int>? // //# export-gen: syntax error
external<int>? // //# external-gen: syntax error
factory<int>? // //# factory-gen: syntax error
get<int>? // //# get-gen: syntax error
implements<int>? // //# implements-gen: syntax error
import<int>? // //# import-gen: syntax error
interface<int>? // //# interface-gen: syntax error
library<int>? // //# library-gen: syntax error
mixin<int>? // //# mixin-gen: syntax error
operator<int>? // //# operator-gen: syntax error
part<int>? // //# part-gen: syntax error
set<int>? // //# set-gen: syntax error
static<int>? // //# static-gen: syntax error
typedef<int>? // //# typedef-gen: syntax error
List<abstract>? // //# abstract-list: syntax error
List<as>? // //# as-list: syntax error
List<covariant>? // //# covariant-list: syntax error
List<deferred>? // //# deferred-list: syntax error
List<dynamic>? // //# dynamic-list: ok
List<export>? // //# export-list: syntax error
List<external>? // //# external-list: syntax error
List<factory>? // //# factory-list: syntax error
List<get>? // //# get-list: syntax error
List<implements>? // //# implements-list: syntax error
List<import>? // //# import-list: syntax error
List<interface>? // //# interface-list: syntax error
List<library>? // //# library-list: syntax error
List<mixin>? // //# mixin-list: syntax error
List<operator>? // //# operator-list: syntax error
List<part>? // //# part-list: syntax error
List<set>? // //# set-list: syntax error
List<static>? // //# static-list: syntax error
List<typedef>? // //# typedef-list: syntax error
Function(abstract)? // //# abstract-funarg: syntax error
Function(as)? // //# as-funarg: syntax error
Function(covariant)? // //# covariant-funarg: syntax error
Function(deferred)? // //# deferred-funarg: syntax error
Function(dynamic)? // //# dynamic-funarg: ok
Function(export)? // //# export-funarg: syntax error
Function(external)? // //# external-funarg: syntax error
Function(factory)? // //# factory-funarg: syntax error
Function(get)? // //# get-funarg: syntax error
Function(implements)? // //# implements-funarg: syntax error
Function(import)? // //# import-funarg: syntax error
Function(interface)? // //# interface-funarg: syntax error
Function(library)? // //# library-funarg: syntax error
Function(mixin)? // //# mixin-funarg: syntax error
Function(operator)? // //# operator-funarg: syntax error
Function(part)? // //# part-funarg: syntax error
Function(set)? // //# set-funarg: syntax error
Function(static)? // //# static-funarg: syntax error
Function(typedef)? // //# typedef-funarg: syntax error
abstract Function()? // //# abstract-funret: syntax error
as Function()? // //# as-funret: syntax error
covariant Function()? // //# covariant-funret: syntax error
deferred Function()? // //# deferred-funret: syntax error
dynamic Function()? // //# dynamic-funret: ok
export Function()? // //# export-funret: syntax error
external Function()? // //# external-funret: syntax error
factory Function()? // //# factory-funret: syntax error
get Function()? // //# get-funret: syntax error
implements Function()? // //# implements-funret: syntax error
import Function()? // //# import-funret: syntax error
interface Function()? // //# interface-funret: syntax error
library Function()? // //# library-funret: syntax error
mixin Function()? // //# mixin-funret: syntax error
operator Function()? // //# operator-funret: syntax error
part Function()? // //# part-funret: syntax error
set Function()? // //# set-funret: syntax error
static Function()? // //# static-funret: syntax error
typedef Function()? // //# typedef-funret: syntax error
x = null;
main() {
x.toString();
}
@@ -0,0 +1,81 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Test that identifiers which are used explicitly in the grammar but are
// not built-in identifiers can be used as library prefixes.
// The identifiers listed below are mentioned in the grammar, but none of
// them is a reserved word or a built-in identifier. Such an identifier can
// be used as a library prefix; this test puts such prefixes in wrong
// locations to verify that this is being handled. Here are the 'known'
// identifiers: `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`.
import "package:expect/expect.dart";
import 'built_in_prefix_library_async.dart' as async;
import 'built_in_prefix_library_await.dart' as await;
import 'built_in_prefix_library_hide.dart' as hide;
import 'built_in_prefix_library_of.dart' as of;
import 'built_in_prefix_library_on.dart' as on;
import 'built_in_prefix_library_show.dart' as show;
import 'built_in_prefix_library_sync.dart' as sync;
import 'built_in_prefix_library_yield.dart' as yield;
main() {
}
@@ -0,0 +1,182 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Test that identifiers which are used explicitly in the grammar but are
// not built-in identifiers can be used as library prefixes.
// The identifiers listed below are mentioned in the grammar, but none of
// them is a reserved word or a built-in identifier. Such an identifier can
// be used as a library prefix; this test puts such prefixes in wrong
// locations to verify that this is being handled. Here are the 'known'
// identifiers: `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`.
import "package:expect/expect.dart";
import 'built_in_prefix_library_async.dart' as async;
import 'built_in_prefix_library_await.dart' as await;
import 'built_in_prefix_library_hide.dart' as hide;
import 'built_in_prefix_library_of.dart' as of;
import 'built_in_prefix_library_on.dart' as on;
import 'built_in_prefix_library_show.dart' as show;
import 'built_in_prefix_library_sync.dart' as sync;
import 'built_in_prefix_library_yield.dart' as yield;
async<dynamic> _async = new async.A();
// [error line 24, column 1, length 5]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'async' isn't a type.
// [error line 24, column 1]
// [cfe] Expected 0 type arguments.
await<dynamic> _await = new await.A();
// [error line 30, column 1, length 5]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'await' isn't a type.
// [error line 30, column 1]
// [cfe] Expected 0 type arguments.
hide<dynamic> _hide = new hide.A();
// [error line 36, column 1, length 4]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'hide' isn't a type.
// [error line 36, column 1]
// [cfe] Expected 0 type arguments.
of<dynamic> _of = new of.A();
// [error line 42, column 1, length 2]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'of' isn't a type.
// [error line 42, column 1]
// [cfe] Expected 0 type arguments.
on<dynamic> _on = new on.A();
// [error line 48, column 1, length 2]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'on' isn't a type.
// [error line 48, column 1]
// [cfe] Expected 0 type arguments.
show<dynamic> _show = new show.A();
// [error line 54, column 1, length 4]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'show' isn't a type.
// [error line 54, column 1]
// [cfe] Expected 0 type arguments.
sync<dynamic> _sync = new sync.A();
// [error line 60, column 1, length 4]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'sync' isn't a type.
// [error line 60, column 1]
// [cfe] Expected 0 type arguments.
yield<dynamic> _yield = new yield.A();
// [error line 66, column 1, length 5]
// [analyzer] STATIC_WARNING.NOT_A_TYPE
// [cfe] 'yield' isn't a type.
// [error line 66, column 1]
// [cfe] Expected 0 type arguments.
async.B<async> _B_async = new async.B();
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'async' isn't a type.
await.B<await> _B_await = new await.B();
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'await' isn't a type.
hide.B<hide> _B_hide = new hide.B();
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'hide' isn't a type.
of.B<of> _B_of = new of.B();
// ^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'of' isn't a type.
on.B<on> _B_on = new on.B();
// ^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'on' isn't a type.
show.B<show> _B_show = new show.B();
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'show' isn't a type.
sync.B<sync> _B_sync = new sync.B();
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'sync' isn't a type.
yield.B<yield> _B_yield = new yield.B();
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'yield' isn't a type.
async.B<async<dynamic>> _B2_async = new async.B();
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'async' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
await.B<await<dynamic>> _B2_await = new await.B();
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'await' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
hide.B<hide<dynamic>> _B2_hide = new hide.B();
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'hide' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
of.B<of<dynamic>> _B2_of = new of.B();
// ^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'of' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
on.B<on<dynamic>> _B2_on = new on.B();
// ^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'on' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
show.B<show<dynamic>> _B2_show = new show.B();
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'show' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
sync.B<sync<dynamic>> _B2_sync = new sync.B();
// ^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'sync' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
yield.B<yield<dynamic>> _B2_yield = new yield.B();
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
// [cfe] 'yield' isn't a type.
// ^
// [cfe] Expected 0 type arguments.
main() {
Expect.isTrue(_async is async.A);
Expect.isTrue(_await is await.A);
Expect.isTrue(_hide is hide.A);
Expect.isTrue(_of is of.A);
Expect.isTrue(_on is on.A);
Expect.isTrue(_show is show.A);
Expect.isTrue(_sync is sync.A);
Expect.isTrue(_yield is yield.A);
Expect.isTrue(_B_async is async.B);
Expect.isTrue(_B_await is await.B);
Expect.isTrue(_B_hide is hide.B);
Expect.isTrue(_B_of is of.B);
Expect.isTrue(_B_on is on.B);
Expect.isTrue(_B_show is show.B);
Expect.isTrue(_B_sync is sync.B);
Expect.isTrue(_B_yield is yield.B);
Expect.isTrue(_B2_async is async.B);
Expect.isTrue(_B2_await is await.B);
Expect.isTrue(_B2_hide is hide.B);
Expect.isTrue(_B2_of is of.B);
Expect.isTrue(_B2_on is on.B);
Expect.isTrue(_B2_show is show.B);
Expect.isTrue(_B2_sync is sync.B);
Expect.isTrue(_B2_yield is yield.B);
}
@@ -0,0 +1,78 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// The identifiers listed below are mentioned in the grammar, but none of
// them is a reserved word or a built-in identifier. Such an identifier can
// be used as library prefix. Here are said 'known' identifiers:
//
// `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`.
import "package:expect/expect.dart";
import 'built_in_prefix_library_async.dart' as async;
import 'built_in_prefix_library_await.dart' as await;
import 'built_in_prefix_library_hide.dart' as hide;
import 'built_in_prefix_library_of.dart' as of;
import 'built_in_prefix_library_on.dart' as on;
import 'built_in_prefix_library_show.dart' as show;
import 'built_in_prefix_library_sync.dart' as sync;
import 'built_in_prefix_library_yield.dart' as yield;
async.A _async = new async.A();
await.A _await = new await.A();
hide.A _hide = new hide.A();
of.A _of = new of.A();
on.A _on = new on.A();
show.A _show = new show.A();
sync.A _sync = new sync.A();
yield.A _yield = new yield.A();
async.B<dynamic> dynamic_B_async = new async.B();
await.B<dynamic> dynamic_B_await = new await.B();
hide.B<dynamic> dynamic_B_hide = new hide.B();
of.B<dynamic> dynamic_B_of = new of.B();
on.B<dynamic> dynamic_B_on = new on.B();
show.B<dynamic> dynamic_B_show = new show.B();
sync.B<dynamic> dynamic_B_sync = new sync.B();
yield.B<dynamic> dynamic_B_yield = new yield.B();
class UseA {
async.A _async = new async.A();
await.A _await = new await.A();
hide.A _hide = new hide.A();
of.A _of = new of.A();
on.A _on = new on.A();
show.A _show = new show.A();
sync.A _sync = new sync.A();
yield.A _yield = new yield.A();
}
main() {
Expect.isTrue(_async is async.A);
Expect.isTrue(_await is await.A);
Expect.isTrue(_hide is hide.A);
Expect.isTrue(_of is of.A);
Expect.isTrue(_on is on.A);
Expect.isTrue(_show is show.A);
Expect.isTrue(_sync is sync.A);
Expect.isTrue(_yield is yield.A);
Expect.isTrue(dynamic_B_async is async.B);
Expect.isTrue(dynamic_B_await is await.B);
Expect.isTrue(dynamic_B_hide is hide.B);
Expect.isTrue(dynamic_B_of is of.B);
Expect.isTrue(dynamic_B_on is on.B);
Expect.isTrue(dynamic_B_show is show.B);
Expect.isTrue(dynamic_B_sync is sync.B);
Expect.isTrue(dynamic_B_yield is yield.B);
var x = new UseA();
Expect.isTrue(x._async is async.A);
Expect.isTrue(x._await is await.A);
Expect.isTrue(x._hide is hide.A);
Expect.isTrue(x._of is of.A);
Expect.isTrue(x._on is on.A);
Expect.isTrue(x._show is show.A);
Expect.isTrue(x._sync is sync.A);
Expect.isTrue(x._yield is yield.A);
}
@@ -0,0 +1,76 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// The identifiers listed below are mentioned in the grammar, but none of
// them is a reserved word or a built-in identifier. Such an identifier can
// be used just like all other identifiers, with the exceptions mentioned
// below. Here are said 'known' identifiers:
//
// `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`
//
// The following exceptions apply:
//
// It is a compile-time error to use `await` or `yield` as an identifier in
// the body of a function marked `async`, `async*`, or `sync*`.
//
// It is a compile-time error if an asynchronous for-in appears inside a
// synchronous function.
import 'dart:async';
Future<void> f1() async {
// Allowed:
int async = 1;
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (int i in s) {
return;
}
}
Stream<int> f2() async* {
int async = 1;
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (var i in s) {
yield i + 1;
}
}
Iterable<int> f3() sync* {
int async = 1;
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
}
void f4() {
int async = 1;
int await = 1;
int yield = 1;
Stream s = new Stream<int>.fromFuture(new Future<int>.value(1));
}
main() {
Future<void> f = f1();
Stream s = f2();
Iterable<int> i = f3();
f4();
}
@@ -0,0 +1,97 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// The identifiers listed below are mentioned in the grammar, but none of
// them is a reserved word or a built-in identifier. Such an identifier can
// be used just like all other identifiers, with the exceptions mentioned
// below. Here are said 'known' identifiers:
//
// `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`
//
// The following exceptions apply:
//
// It is a compile-time error to use `await` or `yield` as an identifier in
// the body of a function marked `async`, `async*`, or `sync*`.
//
// It is a compile-time error if an asynchronous for-in appears inside a
// synchronous function.
import 'dart:async';
Future<void> f1() async {
// Allowed:
int async = 1;
int await = 1;
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
// [cfe] 'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
int yield = 1;
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
// [cfe] 'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (int i in s) {
return;
}
}
Stream<int> f2() async* {
int async = 1;
int await = 1;
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
// [cfe] 'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
int yield = 1;
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
// [cfe] 'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (var i in s) {
yield i + 1;
}
}
Iterable<int> f3() sync* {
int async = 1;
int await = 1;
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
// [cfe] 'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
int yield = 1;
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
// [cfe] 'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (int i in s) {
// ^^
// [analyzer] COMPILE_TIME_ERROR.ASYNC_FOR_IN_WRONG_CONTEXT
// [cfe] The asynchronous for-in can only be used in functions marked with 'async' or 'async*'.
yield i + 1;
}
}
void f4() {
int async = 1;
int await = 1;
int yield = 1;
Stream s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (int i in s) {
// ^^
// [analyzer] COMPILE_TIME_ERROR.ASYNC_FOR_IN_WRONG_CONTEXT
// [cfe] The asynchronous for-in can only be used in functions marked with 'async' or 'async*'.
return;
}
}
main() {
Future<void> f = f1();
Stream s = f2();
Iterable<int> i = f3();
f4();
}
@@ -0,0 +1,370 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// The identifiers listed below are mentioned in the grammar, but none of
// them is a reserved word or a built-in identifier. Such an identifier can
// be used just like all other identifiers, with a few exceptions. Here are
// said 'known' identifiers:
//
// `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`
//
// This test contains various declarations of entities whose name is one of
// these known identifiers.
// Top level.
var async; //# 01: ok
var await; //# 01: continued
var hide; //# 01: continued
var of; //# 01: continued
var on; //# 01: continued
var show; //# 01: continued
var sync; //# 01: continued
var yield; //# 01: continued
int? async; //# 02: ok
int? await; //# 02: continued
int? hide; //# 02: continued
int? of; //# 02: continued
int? on; //# 02: continued
int? show; //# 02: continued
int? sync; //# 02: continued
int? yield; //# 02: continued
final String async = ""; //# 03: ok
final String await = ""; //# 03: continued
final String hide = ""; //# 03: continued
final String of = ""; //# 03: continued
final String on = ""; //# 03: continued
final String show = ""; //# 03: continued
final String sync = ""; //# 03: continued
final String yield = ""; //# 03: continued
const async = null; //# 04: ok
const await = null; //# 04: continued
const hide = null; //# 04: continued
const of = null; //# 04: continued
const on = null; //# 04: continued
const show = null; //# 04: continued
const sync = null; //# 04: continued
const yield = null; //# 04: continued
void async() {} //# 05: ok
void await() {} //# 05: continued
void hide() {} //# 05: continued
void of() {} //# 05: continued
void on() {} //# 05: continued
void show() {} //# 05: continued
void sync() {} //# 05: continued
void yield() {} //# 05: continued
void f1(async, await, hide, of, on, show, sync, yield) {}
void f2([async, await, hide, of, on, show, sync, yield]) {}
void f3({async, await, hide, of, on, show, sync, yield}) {}
void f4(
int async,
int await,
int hide,
int of,
int on,
int show,
int sync,
int yield,
) {}
void f5([
int? async,
int? await,
int? hide,
int? of,
int? on,
int? show,
int? sync,
int? yield,
]) {}
void f6({
int? async,
int? await,
int? hide,
int? of,
int? on,
int? show,
int? sync,
int? yield,
}) {}
class A {
var async; //# 01: continued
var await; //# 01: continued
var hide; //# 01: continued
var of; //# 01: continued
var on; //# 01: continued
var show; //# 01: continued
var sync; //# 01: continued
var yield; //# 01: continued
num? async; //# 02: continued
num? await; //# 02: continued
num? hide; //# 02: continued
num? of; //# 02: continued
num? on; //# 02: continued
num? show; //# 02: continued
num? sync; //# 02: continued
num? yield; //# 02: continued
final String async = ""; //# 03: continued
final String await = ""; //# 03: continued
final String hide = ""; //# 03: continued
final String of = ""; //# 03: continued
final String on = ""; //# 03: continued
final String show = ""; //# 03: continued
final String sync = ""; //# 03: continued
final String yield = ""; //# 03: continued
String get async => ""; //# 04: continued
String get await => ""; //# 04: continued
String get hide => ""; //# 04: continued
String get of => ""; //# 04: continued
String get on => ""; //# 04: continued
String get show => ""; //# 04: continued
String get sync => ""; //# 04: continued
String get yield => ""; //# 04: continued
void async() {} //# 05: ok
void await() {} //# 05: continued
void hide() {} //# 05: continued
void of() {} //# 05: continued
void on() {} //# 05: continued
void show() {} //# 05: continued
void sync() {} //# 05: continued
void yield() {} //# 05: continued
A();
A.c1( //# 01: continued
this.async, //# 01: continued
this.await, //# 01: continued
this.hide, //# 01: continued
this.of, //# 01: continued
this.on, //# 01: continued
this.show, //# 01: continued
this.sync, //# 01: continued
this.yield, //# 01: continued
) {} //# 01: continued
A.c2([ //# 01: continued
this.async, //# 01: continued
this.await, //# 01: continued
this.hide, //# 01: continued
this.of, //# 01: continued
this.on, //# 01: continued
this.show, //# 01: continued
this.sync, //# 01: continued
this.yield, //# 01: continued
]) {} //# 01: continued
A.c3({ //# 01: continued
this.async, //# 01: continued
this.await, //# 01: continued
this.hide, //# 01: continued
this.of, //# 01: continued
this.on, //# 01: continued
this.show, //# 01: continued
this.sync, //# 01: continued
this.yield, //# 01: continued
}) {} //# 01: continued
A.c4( //# 02: continued
int this.async, //# 02: continued
int this.await, //# 02: continued
int this.hide, //# 02: continued
int this.of, //# 02: continued
int this.on, //# 02: continued
int this.show, //# 02: continued
int this.sync, //# 02: continued
int this.yield, //# 02: continued
) {} //# 02: continued
A.c5([ //# 02: continued
int? this.async, //# 02: continued
int? this.await, //# 02: continued
int? this.hide, //# 02: continued
int? this.of, //# 02: continued
int? this.on, //# 02: continued
int? this.show, //# 02: continued
int? this.sync, //# 02: continued
int? this.yield, //# 02: continued
]) {} //# 02: continued
A.c6({ //# 02: continued
int? this.async, //# 02: continued
int? this.await, //# 02: continued
int? this.hide, //# 02: continued
int? this.of, //# 02: continued
int? this.on, //# 02: continued
int? this.show, //# 02: continued
int? this.sync, //# 02: continued
int? this.yield, //# 02: continued
}) {} //# 02: continued
void method1(
covariant int async,
covariant int await,
covariant int hide,
covariant int of,
covariant int on,
covariant int show,
covariant int sync,
covariant int yield,
) {}
void method2([
covariant int? async,
covariant int? await,
covariant int? hide,
covariant int? of,
covariant int? on,
covariant int? show,
covariant int? sync,
covariant int? yield,
]) {}
void method3({
covariant int? async,
covariant int? await,
covariant int? hide,
covariant int? of,
covariant int? on,
covariant int? show,
covariant int? sync,
covariant int? yield,
}) {}
}
class B {
static var async; //# 01: continued
static var await; //# 01: continued
static var hide; //# 01: continued
static var of; //# 01: continued
static var on; //# 01: continued
static var show; //# 01: continued
static var sync; //# 01: continued
static var yield; //# 01: continued
static num? async; //# 02: continued
static num? await; //# 02: continued
static num? hide; //# 02: continued
static num? of; //# 02: continued
static num? on; //# 02: continued
static num? show; //# 02: continued
static num? sync; //# 02: continued
static num? yield; //# 02: continued
static final String async = ""; //# 03: continued
static final String await = ""; //# 03: continued
static final String hide = ""; //# 03: continued
static final String of = ""; //# 03: continued
static final String on = ""; //# 03: continued
static final String show = ""; //# 03: continued
static final String sync = ""; //# 03: continued
static final String yield = ""; //# 03: continued
static const async = null; //# 04: continued
static const await = null; //# 04: continued
static const hide = null; //# 04: continued
static const of = null; //# 04: continued
static const on = null; //# 04: continued
static const show = null; //# 04: continued
static const sync = null; //# 04: continued
static const yield = null; //# 04: continued
static get async => null; //# 05: continued
static get await => null; //# 05: continued
static get hide => null; //# 05: continued
static get of => null; //# 05: continued
static get on => null; //# 05: continued
static get show => null; //# 05: continued
static get sync => null; //# 05: continued
static get yield => null; //# 05: continued
}
main() {
/* //# none: ok
// Except none: Use a top-level declaration.
var top_async = async;
var top_await = await;
var top_hide = hide;
var top_of = of;
var top_on = on;
var top_show = show;
var top_sync = sync;
var top_yield = yield;
// Except none: Use an instance member of A.
A a = new A();
var instance_async = a.async;
var instance_await = a.await;
var instance_hide = a.hide;
var instance_of = a.of;
var instance_on = a.on;
var instance_show = a.show;
var instance_sync = a.sync;
var instance_yield = a.yield;
// Except none: Use a static member of B.
var static_async = B.async;
var static_await = B.await;
var static_hide = B.hide;
var static_of = B.of;
var static_on = B.on;
var static_show = B.show;
var static_sync = B.sync;
var static_yield = B.yield;
*/ //# none: continued
var a1 = new A.c1(1, 1, 1, 1, 1, 1, 1, 1); //# 01: continued
var a2 = new A.c2(); //# 01: continued
var a3 = new A.c3( //# 01: continued
async: 1, //# 01: continued
await: 1, //# 01: continued
hide: 1, //# 01: continued
of: 1, //# 01: continued
on: 1, //# 01: continued
show: 1, //# 01: continued
sync: 1, //# 01: continued
yield: 1, //# 01: continued
); //# 01: continued
var a4 = new A.c4(1, 1, 1, 1, 1, 1, 1, 1); //# 02: continued
var a5 = new A.c5(); //# 02: continued
var a6 = new A.c6( //# 02: continued
async: 1, //# 02: continued
await: 1, //# 02: continued
hide: 1, //# 02: continued
of: 1, //# 02: continued
on: 1, //# 02: continued
show: 1, //# 02: continued
sync: 1, //# 02: continued
yield: 1, //# 02: continued
); //# 02: continued
var aa = new A();
aa.method1(1, 1, 1, 1, 1, 1, 1, 1);
aa.method2();
aa.method3(
async: 1,
await: 1,
hide: 1,
of: 1,
on: 1,
show: 1,
sync: 1,
yield: 1,
);
}
@@ -0,0 +1,15 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class A {
var function;
A(function) : function = function;
}
main() {
var a = new A(499);
Expect.equals(499, a.function);
}
@@ -0,0 +1,97 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class A {
var __PROTO__ = 499;
var constructor = 1;
var prototype = 2;
}
// TODO(jmesserly): changed this test to avoid shadowing a field with a getter,
// which DDC doesn't currently support, see:
// https://github.com/dart-lang/dev_compiler/issues/52
class A2 {
get __PROTO__ => 499;
get constructor => 1;
get prototype => 2;
}
class B extends A2 {
get __PROTO__ => 42;
get constructor => 3;
get prototype => 4;
}
class P {
m() => 42;
}
class C {
m() => 777;
static get prototype => new P();
static get name => 'hello from C.name';
static void _check(obj) {
Expect.equals(obj, 'hello');
check_++;
}
static void as(obj) {
Expect.equals(obj, 'world');
as_++;
}
static int as_ = 0;
static int check_ = 0;
}
// Regression test for https://github.com/dart-lang/sdk/issues/31049
regress31049() {
dynamic d = new C();
C c = d; // implicit cast
d as C; // explicit cast
C._check('hello');
Expect.equals(C.check_, 1);
C.as('world');
Expect.equals(C.as_, 1);
}
// Regression test for https://github.com/dart-lang/sdk/issues/31050
regress31050() {
Expect.isFalse((C).toString().contains('C.name'), 'should not call C.name');
Expect.equals(C.name, 'hello from C.name');
Expect.equals(C.prototype.m(), 42);
Expect.equals(new C().m(), 777);
}
var name = 42;
regress31117() {
Expect.equals(name, 42);
}
main() {
var a = new A();
var a2 = new A2();
var b = new B();
var list = <dynamic>[a, a2, b];
for (int i = 0; i < list.length; i++) {
var proto = list[i].__PROTO__;
var constructor = list[i].constructor;
var prototype = list[i].prototype;
if (i < 2) {
Expect.equals(499, proto);
Expect.equals(1, constructor);
Expect.equals(2, prototype);
} else {
Expect.equals(42, proto);
Expect.equals(3, constructor);
Expect.equals(4, prototype);
}
}
regress31049();
regress31050();
regress31117();
}
+528
View File
@@ -0,0 +1,528 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class A {
A() {
NamingTest.count++;
}
foo(a, b) {
Expect.equals(1, a);
Expect.equals(2, b);
}
}
class MyException {
MyException() {}
}
class debugger {
static const int __PROTO__ = 5;
int x;
factory debugger.F() {
return new debugger(1);
}
debugger(x) : this.x = x + 1 {}
debugger.C(x) : this.x = x + 2 {}
debugger.C$C(x) : this.x = x + 3 {}
debugger.C$I(x) : this.x = x + 4 {}
}
class debugger$C {
int x;
factory debugger$C.F() {
return new debugger$C(1);
}
debugger$C(x) : this.x = x + 5 {}
debugger$C.C(x) : this.x = x + 6 {}
debugger$C.C$C(x) : this.x = x + 7 {}
debugger$C.C$I(x) : this.x = x + 8 {}
}
class debugger$C$C {
int x;
factory debugger$C$C.F() {
return new debugger$C$C(1);
}
debugger$C$C(x) : this.x = x + 9 {}
debugger$C$C.C(x) : this.x = x + 10 {}
debugger$C$C.C$C(x) : this.x = x + 11 {}
debugger$C$C.C$I(x) : this.x = x + 12 {}
}
class with$I extends debugger$C {
int y;
factory with$I.F() {
return new with$I(1, 2);
}
with$I(x, y)
: this.y = y + 11,
super(x) {}
with$I.I(x, y)
: this.y = y + 12,
super.C(x) {}
with$I.C(x, y)
: this.y = y + 13,
super.C$C(x){}
with$I.I$C(x, y)
: this.y = y + 14,
super.C$I(x) {}
with$I.C$C(x, y)
: this.y = y + 15,
super(x) {}
with$I.C$C$C(x, y)
: this.y = y + 16,
super.C(x) {}
with$I.$C$I(x, y)
:this.y = y + 17,
super.C$C(x) {}
with$I.$$I$C(x, y)
:this.y = y + 18,
super.C$I(x) {}
with$I.$(x, y)
: this.y = y + 19,
super(x) {}
with$I.$$(x, y)
: this.y = y + 20,
super.C(x) {}
}
class with$C extends debugger$C$C {
int y;
factory with$C.F() {
return new with$C(1, 2);
}
with$C(x, y)
: this.y = y + 21,
super(x) {}
with$C.I(x, y)
: this.y = y + 22,
super.C(x) {}
with$C.C(x, y)
: this.y = y + 23,
super.C$C(x) {}
with$C.I$C(x, y)
: this.y = y + 24,
super.C$I(x) {}
with$C.C$C(x, y)
: this.y = y + 25,
super(x) {}
with$C.C$C$C(x, y)
: this.y = y + 26,
super.C(x) {}
with$C.$C$I(x, y)
: this.y = y + 27,
super.C$C(x) {}
with$C.$$I$C(x, y)
: this.y = y + 28,
super.C$I(x) {}
with$C.$(x, y)
: this.y = y + 29,
super(x) {}
with$C.$$(x, y)
: this.y = y + 30,
super.C(x) {}
}
class with$I$C extends debugger$C$C {
int y;
factory with$I$C.F() {
return new with$I$C(1, 2);
}
with$I$C(x, y)
: this.y = y + 31,
super(x) {}
with$I$C.I(x, y)
: this.y = y + 32,
super.C(x) {}
with$I$C.C(x, y)
: this.y = y + 33,
super.C$C(x) {}
with$I$C.I$C(x, y)
: this.y = y + 34,
super.C$I(x) {}
with$I$C.C$C(x, y)
: this.y = y + 35,
super(x) {}
with$I$C.C$C$C(x, y)
: this.y = y + 36,
super.C(x) {}
with$I$C.$C$I(x, y)
: this.y = y + 37,
super.C$C(x) {}
with$I$C.$$I$C(x, y)
: this.y = y + 38,
super.C$I(x) {}
with$I$C.$(x, y)
: this.y = y + 39,
super(x) {}
with$I$C.$$(x, y)
: this.y = y + 40,
super.C(x) {}
}
class Tata {
var prototype;
Tata() : this.prototype = 0 {}
__PROTO__$() {
return 12;
}
}
class Toto extends Tata {
var __PROTO__;
Toto()
: this.__PROTO__ = 0,
super() {}
prototype$() {
return 10;
}
titi() {
Expect.equals(0, prototype);
Expect.equals(0, __PROTO__);
prototype = 3;
__PROTO__ = 5;
Expect.equals(3, prototype);
Expect.equals(5, __PROTO__);
Expect.equals(10, prototype$());
Expect.equals(12, __PROTO__$());
Expect.equals(12, this.__PROTO__$());
Expect.equals(10, this.prototype$());
Expect.equals(12, __PROTO__$());
}
}
class Bug4082360 {
int x_ = -1;
Bug4082360() {}
int get x {
return x_;
}
void set x(int value) {
x_ = value;
}
void indirectSet(int value) {
x = value;
}
static void test() {
var bug = new Bug4082360();
bug.indirectSet(42);
Expect.equals(42, bug.x_);
Expect.equals(42, bug.x);
}
}
class Hoisting {
var f_;
Hoisting.negate(var x) {
f_ = () {
return x;
};
}
operator -() {
var x = 3;
return () {
return x + 1;
};
}
operator [](x) {
return () {
return x + 3;
};
}
static void test() {
var h = new Hoisting.negate(1);
Expect.equals(1, (h.f_)());
var f = -h;
Expect.equals(4, f());
Expect.equals(7, h[4]());
}
}
// It is not possible to make sure that the backend uses the hardcoded names
// we are testing against. This test might therefore become rapidly out of date
class NamingTest {
static int count = -1;
static testExceptionNaming() {
// Exceptions use a hardcoded "e" as exception name. If the namer works
// correctly then it will be renamed in case of clashes.
var e = 3;
var caught = 0;
try {
throw new MyException();
} catch (exc) {
try {
throw new MyException();
} catch (exc2) {
caught++;
}
Expect.equals(1, caught);
caught++;
}
Expect.equals(2, caught);
Expect.equals(3, e);
}
static testTmpNaming() {
Expect.equals(0, count);
var tmp$0 = 1;
var tmp$1 = 2;
new A().foo(tmp$0, tmp$1++);
Expect.equals(1, count);
Expect.equals(3, tmp$1);
}
static testScopeNaming() {
// Alias scopes use a hardcoded "dartc_scp$<depth>" as names.
var dartc_scp$1 = 5;
var foo = 8;
var f = () {
var dartc_scp$1 = 15;
return foo + dartc_scp$1;
};
Expect.equals(5, dartc_scp$1);
Expect.equals(23, f());
}
static testGlobalMangling() {
var x;
x = new debugger(0);
Expect.equals(1, x.x);
x = new debugger.C(0);
Expect.equals(2, x.x);
x = new debugger.C$C(0);
Expect.equals(3, x.x);
x = new debugger.C$I(0);
Expect.equals(4, x.x);
x = new debugger$C(0);
Expect.equals(5, x.x);
x = new debugger$C.C(0);
Expect.equals(6, x.x);
x = new debugger$C.C$C(0);
Expect.equals(7, x.x);
x = new debugger$C.C$I(0);
Expect.equals(8, x.x);
x = new debugger$C$C(0);
Expect.equals(9, x.x);
x = new debugger$C$C.C(0);
Expect.equals(10, x.x);
x = new debugger$C$C.C$C(0);
Expect.equals(11, x.x);
x = new debugger$C$C.C$I(0);
Expect.equals(12, x.x);
x = new with$I(0, 0);
Expect.equals(5, x.x);
Expect.equals(11, x.y);
x = new with$I.I(0, 0);
Expect.equals(6, x.x);
Expect.equals(12, x.y);
x = new with$I.C(0, 0);
Expect.equals(7, x.x);
Expect.equals(13, x.y);
x = new with$I.I$C(0, 0);
Expect.equals(8, x.x);
Expect.equals(14, x.y);
x = new with$I.C$C(0, 0);
Expect.equals(5, x.x);
Expect.equals(15, x.y);
x = new with$I.C$C$C(0, 0);
Expect.equals(6, x.x);
Expect.equals(16, x.y);
x = new with$I.$C$I(0, 0);
Expect.equals(7, x.x);
Expect.equals(17, x.y);
x = new with$I.$$I$C(0, 0);
Expect.equals(8, x.x);
Expect.equals(18, x.y);
x = new with$I.$(0, 0);
Expect.equals(5, x.x);
Expect.equals(19, x.y);
x = new with$I.$$(0, 0);
Expect.equals(6, x.x);
Expect.equals(20, x.y);
x = new with$C(0, 0);
Expect.equals(9, x.x);
Expect.equals(21, x.y);
x = new with$C.I(0, 0);
Expect.equals(10, x.x);
Expect.equals(22, x.y);
x = new with$C.C(0, 0);
Expect.equals(11, x.x);
Expect.equals(23, x.y);
x = new with$C.I$C(0, 0);
Expect.equals(12, x.x);
Expect.equals(24, x.y);
x = new with$C.C$C(0, 0);
Expect.equals(9, x.x);
Expect.equals(25, x.y);
x = new with$C.C$C$C(0, 0);
Expect.equals(10, x.x);
Expect.equals(26, x.y);
x = new with$C.$C$I(0, 0);
Expect.equals(11, x.x);
Expect.equals(27, x.y);
x = new with$C.$$I$C(0, 0);
Expect.equals(12, x.x);
Expect.equals(28, x.y);
x = new with$C.$(0, 0);
Expect.equals(9, x.x);
Expect.equals(29, x.y);
x = new with$C.$$(0, 0);
Expect.equals(10, x.x);
Expect.equals(30, x.y);
x = new with$I$C(0, 0);
Expect.equals(9, x.x);
Expect.equals(31, x.y);
x = new with$I$C.I(0, 0);
Expect.equals(10, x.x);
Expect.equals(32, x.y);
x = new with$I$C.C(0, 0);
Expect.equals(11, x.x);
Expect.equals(33, x.y);
x = new with$I$C.I$C(0, 0);
Expect.equals(12, x.x);
Expect.equals(34, x.y);
x = new with$I$C.C$C(0, 0);
Expect.equals(9, x.x);
Expect.equals(35, x.y);
x = new with$I$C.C$C$C(0, 0);
Expect.equals(10, x.x);
Expect.equals(36, x.y);
x = new with$I$C.$C$I(0, 0);
Expect.equals(11, x.x);
Expect.equals(37, x.y);
x = new with$I$C.$$I$C(0, 0);
Expect.equals(12, x.x);
Expect.equals(38, x.y);
x = new with$I$C.$(0, 0);
Expect.equals(9, x.x);
Expect.equals(39, x.y);
x = new with$I$C.$$(0, 0);
Expect.equals(10, x.x);
Expect.equals(40, x.y);
}
static void testMemberMangling() {
Expect.equals(5, debugger.__PROTO__);
new Toto().titi();
}
static void testFactoryMangling() {
var o = new debugger.F() as dynamic;
Expect.equals(2, o.x);
o = new debugger$C.F();
Expect.equals(6, o.x);
o = new debugger$C$C.F();
Expect.equals(10, o.x);
o = new with$I.F();
Expect.equals(6, o.x);
Expect.equals(13, o.y);
o = new with$C.F();
Expect.equals(10, o.x);
Expect.equals(23, o.y);
o = new with$I$C.F();
Expect.equals(10, o.x);
Expect.equals(33, o.y);
}
static testFunctionParameters() {
a(eval) {
return eval;
}
b(arguments) {
return arguments;
}
Expect.equals(10, a(10));
Expect.equals(10, b(10));
}
static testPseudoTokens() {
var EOS = 400;
var ILLEGAL = 99;
Expect.equals(499, EOS + ILLEGAL);
}
static testDollar() {
Expect.equals(123, $(123).wrapped);
var x = new Object(), y = new Object();
Expect.identical(x, $(x).wrapped);
Expect.identical(y, $(x).$add(y));
Expect.identical(x, $(x).$negate());
Expect.equals(123, $(x) + x);
Expect.equals(444, -$(x));
}
static void testMain() {
count = 0;
testExceptionNaming();
testTmpNaming();
testScopeNaming();
testGlobalMangling();
testMemberMangling();
testFactoryMangling();
testFunctionParameters();
Bug4082360.test();
Hoisting.test();
testPseudoTokens();
testDollar();
}
}
// Test that the generated JS names don't conflict with "$"
class DartQuery {
Object wrapped;
DartQuery(this.wrapped);
$add(Object other) => other;
$negate() => wrapped;
operator +(Object other) => 123;
operator -() => 444;
}
$add(Object first, Object second) => second;
DartQuery $(Object obj) => new DartQuery(obj);
// Ensure we don't have false positive.
class Naming2Test {
Naming2Test() {}
int get foo {
return 1;
}
set foo(x) {}
static void main(args) {
var a = new Naming2Test() as dynamic;
Expect.throwsNoSuchMethodError(() => a.foo(2));
}
}
main() {
NamingTest.testMain();
Naming2Test.main(null);
}
@@ -14,9 +14,8 @@
//
// The following exceptions apply:
//
// It is a compile-time error to use `async`, `await`, or `yield` as an
// identifier in the body of a function marked `async`, `async*`, or
// `sync*`.
// It is a compile-time error to use `await` or `yield` as an identifier in
// the body of a function marked `async`, `async*`, or `sync*`.
//
// It is a compile-time error if an asynchronous for-in appears inside a
// synchronous function.
@@ -24,6 +23,7 @@
import 'dart:async';
Future<int> f1() async {
// Allowed:
int async = 1;
@@ -11,9 +11,8 @@
//
// The following exceptions apply:
//
// It is a compile-time error to use `async`, `await`, or `yield` as an
// identifier in the body of a function marked `async`, `async*`, or
// `sync*`.
// It is a compile-time error to use `await` or `yield` as an identifier in
// the body of a function marked `async`, `async*`, or `sync*`.
//
// It is a compile-time error if an asynchronous for-in appears inside a
// synchronous function.
@@ -21,6 +20,7 @@
import 'dart:async';
Future<int> f1() async {
// Allowed:
int async = 1;
int await = 1;
// ^^^^^