Migrate language_2/prefix to NNBD.

Change-Id: I5149b18d796c6991404c22322e5fb4b4c8372613
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150287
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Robert Nystrom
2020-06-06 01:44:40 +00:00
committed by commit-bot@chromium.org
parent c959c9aba7
commit 578fa6bee9
46 changed files with 1108 additions and 0 deletions
@@ -0,0 +1,29 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2015, 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.
// Validate that assignment to a prefix is handled consistently with the
// following spec text from section 16.19 (Assignment):
// Evaluation of an assignment a of the form v = e proceeds as follows:
// Let d be the innermost declaration whose name is v or v=, if it exists.
// It is a compile-time error if d denotes a prefix object.
import "empty_library.dart" as p;
class Base {
var p;
}
class Derived extends Base {
void f() {
}
}
main() {
new Derived().f();
}
@@ -0,0 +1,32 @@
// Copyright (c) 2015, 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.
// Validate that assignment to a prefix is handled consistently with the
// following spec text from section 16.19 (Assignment):
// Evaluation of an assignment a of the form v = e proceeds as follows:
// Let d be the innermost declaration whose name is v or v=, if it exists.
// It is a compile-time error if d denotes a prefix object.
import "empty_library.dart" as p;
class Base {
var p;
}
class Derived extends Base {
void f() {
p = 1;
// ^
// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
// [cfe] A prefix can't be used as an expression.
}
}
main() {
new Derived().f();
p = 1;
//^
// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
// [cfe] A prefix can't be used as an expression.
}
+5
View File
@@ -0,0 +1,5 @@
// Copyright (c) 2015, 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 empty_library;
@@ -0,0 +1,25 @@
// Copyright (c) 2015, 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.
// Validate the following spec text from section 16.32 (Identifier Reference):
// Evaluation of an identifier expression e of the form id proceeds as
// follows:
// Let d be the innermost declaration in the enclosing lexical scope whose
// name is id or id=. If no such declaration exists in the lexical scope,
// d be the declaration of the inherited member named id if it exists.
// - If d is a prefix p, a compile-time error occurs unless the token
// immediately following d is '.'.
import "package:expect/expect.dart";
import "empty_library.dart" as p;
void f(x) {}
main() {
f(p); // //# 01: compile-time error
var x = p; // //# 02: compile-time error
var x = p[0]; //# 03: compile-time error
p[0] = null; // //# 04: compile-time error
p += 0; // //# 05: compile-time error
}
@@ -0,0 +1,16 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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.
// Using the same prefix name while importing two different libraries is
// not an error but both library1.dart and library2.dart define 'foo' which
// results in a duplicate definition error.
import "../library1.dart" as lib2; // defines 'foo'.
import "../library2.dart" as lib2; // also defines 'foo'.
main() {
}
@@ -0,0 +1,16 @@
// 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.
// Using the same prefix name while importing two different libraries is
// not an error but both library1.dart and library2.dart define 'foo' which
// results in a duplicate definition error.
import "../library1.dart" as lib2; // defines 'foo'.
import "../library2.dart" as lib2; // also defines 'foo'.
main() {
lib2.foo = 1;
// ^^^
// [analyzer] STATIC_WARNING.AMBIGUOUS_IMPORT
// [cfe] Setter not found: 'foo'.
}
@@ -0,0 +1,13 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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.
// Prefix must be a valid identifier.
import "../library1.dart"
;
main() {}
@@ -0,0 +1,19 @@
// 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.
// Prefix must be a valid identifier.
import "../library1.dart"
as lib1.invalid
// ^^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected ';' after this.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
// [cfe] Expected a declaration, but got '.'.
// ^^^^^^^
// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
;
main() {}
+12
View File
@@ -0,0 +1,12 @@
// 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 PrefixTest;
import "package:expect/expect.dart";
import "test1.dart";
main() {
Expect.equals(Prefix.getSource(), Prefix.getImport() + 1);
}
+19
View File
@@ -0,0 +1,19 @@
// 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 PrefixTest1;
import "test2.dart" as test2;
class Prefix {
static const int foo = 43;
static getSource() {
return foo;
}
static getImport() {
return test2.Prefix.foo;
}
}
+9
View File
@@ -0,0 +1,9 @@
// 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 PrefixNewTest2;
class Prefix {
static const int foo = 42;
}
+57
View File
@@ -0,0 +1,57 @@
// 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.
// Test to check if we are able to import multiple libraries using the
// same prefix.
library Prefix101Test.dart;
import "package:expect/expect.dart";
import "../library10.dart" as lib101;
import "../library11.dart" as lib101;
class Prefix101Test {
static Test1() {
var result = 0;
var obj = new lib101.Library10(1);
result = obj.fld;
Expect.equals(1, result);
result += obj.func();
Expect.equals(3, result);
result += lib101.Library10.static_func();
Expect.equals(6, result);
result += lib101.Library10.static_fld;
Expect.equals(10, result);
}
static Test2() {
var result = 0;
var obj = new lib101.Library11(4);
result = obj.fld;
Expect.equals(4, result);
result += obj.func();
Expect.equals(7, result);
result += lib101.Library11.static_func();
Expect.equals(9, result);
result += lib101.Library11.static_fld;
Expect.equals(10, result);
}
static Test3() {
Expect.equals(10, lib101.top_level10);
Expect.equals(20, lib101.top_level_func10());
}
static Test4() {
Expect.equals(100, lib101.top_level11);
Expect.equals(200, lib101.top_level_func11());
}
}
main() {
Prefix101Test.Test1();
Prefix101Test.Test2();
Prefix101Test.Test3();
Prefix101Test.Test4();
}
+54
View File
@@ -0,0 +1,54 @@
// 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.
library Prefix10Test.dart;
import "package:expect/expect.dart";
import "../library10.dart" as lib10;
import "../library11.dart" as lib11;
class Prefix10Test {
static Test1() {
var result = 0;
var obj = new lib10.Library10(1);
result = obj.fld;
Expect.equals(1, result);
result += obj.func();
Expect.equals(3, result);
result += lib10.Library10.static_func();
Expect.equals(6, result);
result += lib10.Library10.static_fld;
Expect.equals(10, result);
}
static Test2() {
var result = 0;
var obj = new lib11.Library11(4);
result = obj.fld;
Expect.equals(4, result);
result += obj.func();
Expect.equals(7, result);
result += lib11.Library11.static_func();
Expect.equals(9, result);
result += lib11.Library11.static_fld;
Expect.equals(10, result);
}
static Test3() {
Expect.equals(10, lib10.top_level10);
Expect.equals(20, lib10.top_level_func10());
}
static Test4() {
Expect.equals(100, lib11.top_level11);
Expect.equals(200, lib11.top_level_func11());
}
}
main() {
Prefix10Test.Test1();
Prefix10Test.Test2();
Prefix10Test.Test3();
Prefix10Test.Test4();
}
+55
View File
@@ -0,0 +1,55 @@
// 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.
//
library Prefix11Test.dart;
import "package:expect/expect.dart";
import "../library10.dart";
import "../library11.dart" as lib11;
class Prefix11Test {
static Test1() {
var result = 0;
var obj = new Library10(1);
result = obj.fld;
Expect.equals(1, result);
result += obj.func();
Expect.equals(3, result);
result += Library10.static_func();
Expect.equals(6, result);
result += Library10.static_fld;
Expect.equals(10, result);
}
static Test2() {
var result = 0;
var obj = new lib11.Library11(4);
result = obj.fld;
Expect.equals(4, result);
result += obj.func();
Expect.equals(7, result);
result += lib11.Library11.static_func();
Expect.equals(9, result);
result += lib11.Library11.static_fld;
Expect.equals(10, result);
}
static Test3() {
Expect.equals(10, top_level10);
Expect.equals(20, top_level_func10());
}
static Test4() {
Expect.equals(100, lib11.top_level11);
Expect.equals(200, lib11.top_level_func11());
}
}
main() {
Prefix11Test.Test1();
Prefix11Test.Test2();
Prefix11Test.Test3();
Prefix11Test.Test4();
}
+30
View File
@@ -0,0 +1,30 @@
// 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.
//
library Prefix12Test.dart;
import "package:expect/expect.dart";
import "../library11.dart" as lib11;
class Prefix12Test {
static Test1() {
var result = 0;
var obj = new lib11.Library11.namedConstructor(10);
result = obj.fld;
Expect.equals(10, result);
}
static Test2() {
int result = 0;
var obj = new lib11.Library111<int>.namedConstructor(10);
result = obj.fld;
Expect.equals(10, result);
}
}
main() {
Prefix12Test.Test1();
Prefix12Test.Test2();
}
+71
View File
@@ -0,0 +1,71 @@
// 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.
//
// Use qualified symbols at various places.
library Prefix14Test.dart;
import "package:expect/expect.dart";
import "../library12.dart" as lib12;
typedef lib12.Library12 myFunc(lib12.Library12 param);
class myInterface implements lib12.Library12Interface {
myInterface(lib12.Library12 this.myfld);
lib12.Library12 addObjects(lib12.Library12 value1, lib12.Library12 value2) {
myfld.fld = (value1.fld + value2.fld + myfld.fld);
return myfld;
}
lib12.Library12 myfld;
}
class myClass extends lib12.Library12 {
myClass(int value) : super(value);
static lib12.Library12 func1() {
var i = new lib12.Library12(10);
return i;
}
static lib12.Library12 func2(lib12.Library12 param) {
return param;
}
}
class myClass1 {
myClass1(int value) : fld1 = new lib12.Library12(value);
lib12.Library12 fld1;
}
class myClass2 {
myClass2(lib12.Library12 this.fld2);
lib12.Library12 fld2;
}
main() {
var o;
o = myClass.func1();
Expect.equals(2, o.func());
o = new myClass(10);
Expect.equals(10, o.fld);
myFunc func = myClass.func2;
Expect.equals(2, func(new lib12.Library12(10)).func());
Expect.equals(10, func(new lib12.Library12(10)).fld);
o = new myClass1(100);
Expect.equals(2, o.fld1.func());
Expect.equals(100, o.fld1.fld);
o = new myClass2(new lib12.Library12(200));
Expect.equals(2, o.fld2.func());
Expect.equals(200, o.fld2.fld);
o = new myInterface(new lib12.Library12(100));
Expect.equals(2, o.myfld.func());
Expect.equals(100, o.myfld.fld);
o = o.addObjects(new lib12.Library12(200), new lib12.Library12(300));
Expect.equals(2, o.func());
Expect.equals(600, o.fld);
}
+48
View File
@@ -0,0 +1,48 @@
// 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.
//
// Use qualified symbols with generics at various places.
library Prefix15Test.dart;
import "package:expect/expect.dart";
import "../library12.dart" as lib12;
typedef T myFunc<T>(T param);
class myInterface<T extends lib12.Library12>
implements lib12.Library12Interface {
myInterface(T this.myfld);
T addObjects(covariant T value1, covariant T value2) {
myfld.fld = (value1.fld + value2.fld + myfld.fld);
return myfld;
}
T myfld;
}
class myClass2<T> {
myClass2(T this.fld2);
T func(T val) => val;
T fld2;
}
main() {
var o;
o = new myClass2<lib12.Library12>(new lib12.Library12(100));
myFunc<lib12.Library12> func = o.func;
Expect.equals(2, func(new lib12.Library12(10)).func());
Expect.equals(10, func(new lib12.Library12(10)).fld);
o = new myClass2<lib12.Library12>(new lib12.Library12(200));
Expect.equals(2, o.fld2.func());
Expect.equals(200, o.fld2.fld);
o = new myInterface<lib12.Library12>(new lib12.Library12(100));
Expect.equals(2, o.myfld.func());
Expect.equals(100, o.myfld.fld);
o = o.addObjects(new lib12.Library12(200), new lib12.Library12(300));
Expect.equals(2, o.func());
Expect.equals(600, o.fld);
}
@@ -0,0 +1,30 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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.
//
// Unresolved imported symbols are errors.
// In this test, the function myFunc contains malformed types because
// lib12.Library13 is not resolved.
import "package:expect/expect.dart";
import "../library12.dart" as lib12;
typedef
myFunc(
param);
typedef
myFunc2(
param, int i);
main() {
Expect.isTrue(((Object? x) => x) is myFunc);
Expect.isTrue(((Object? x, int y) => x) is myFunc2);
Expect.isFalse(((Object? x, String y) => x) is myFunc2);
}
+39
View File
@@ -0,0 +1,39 @@
// 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.
//
// Unresolved imported symbols are errors.
// In this test, the function myFunc contains malformed types because
// lib12.Library13 is not resolved.
import "package:expect/expect.dart";
import "../library12.dart" as lib12;
typedef
lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] Type 'lib12.Library13' not found.
myFunc(
lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] Type 'lib12.Library13' not found.
param);
typedef
lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] Type 'lib12.Library13' not found.
myFunc2(
lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] Type 'lib12.Library13' not found.
param, int i);
main() {
Expect.isTrue(((Object x) => x) is myFunc);
Expect.isTrue(((Object x, int y) => x) is myFunc2);
Expect.isFalse(((Object x, String y) => x) is myFunc2);
}
+19
View File
@@ -0,0 +1,19 @@
// 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.
library Prefix17Test.dart;
import "../library12.dart" as lib12;
class LocalClass {
static int static_fld = 42;
}
void main() {
var lc1 = new lib12.Library12(5);
lib12.Library12 lc2 = new lib12.Library12(10);
lib12.Library12 lc2m = new lib12.Library12.other(10, 2);
lib12.Library12.static_fld = 43;
//print("${LocalClass.static_fld}, ${lc1.fld}, ${lc2.fld}, ${lc2m.fld}, ${lib12.Library12.static_fld}");
}
@@ -0,0 +1,13 @@
// 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.
library Prefix21Bad;
int badFunction(int x) {
return x << 1;
}
Function get getValue {
return badFunction;
}
@@ -0,0 +1,13 @@
// 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.
library Prefix21Good;
int goodFunction(int x) {
return x;
}
Function get getValue {
return goodFunction;
}
+14
View File
@@ -0,0 +1,14 @@
// 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.
library Prefix21;
import "package:expect/expect.dart";
import "prefix21_good_lib.dart" as good;
import "prefix21_bad_lib.dart" as bad;
main() {
Expect.equals(good.getValue(42), 42);
Expect.equals(bad.getValue(42), 84);
}
@@ -0,0 +1,22 @@
// 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.
//
// Unresolved symbols should be reported as static type warnings.
// This should not prevent execution.
library Prefix21NegativeTest.dart;
import "../library12.dart" as lib12;
class myClass {
myClass(
p) { }
}
main() {
new myClass(null); // no dynamic type error when assigning null
}
+24
View File
@@ -0,0 +1,24 @@
// 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.
//
// Unresolved symbols should be reported as static type warnings.
// This should not prevent execution.
library Prefix21NegativeTest.dart;
import "../library12.dart" as lib12;
class myClass {
myClass(
lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] Type 'lib12.Library13' not found.
// ^
// [cfe] 'Library13' isn't a type.
p) { }
}
main() {
new myClass(null); // no dynamic type error when assigning null
}
@@ -0,0 +1,21 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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.
//
// Unresolved symbols should be reported as an static type warnings.
// This should not prevent execution.
library Prefix23Test.dart;
import "../library12.dart" as lib12;
class myClass {
final
fld = null;
}
main() {}
+23
View File
@@ -0,0 +1,23 @@
// 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.
//
// Unresolved symbols should be reported as an static type warnings.
// This should not prevent execution.
library Prefix23Test.dart;
import "../library12.dart" as lib12;
class myClass {
final
lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] Type 'lib12.Library13' not found.
// ^
// [cfe] 'Library13' isn't a type.
fld = null;
}
main() {}
+10
View File
@@ -0,0 +1,10 @@
// Copyright (c) 2013, 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 prefix24_lib1;
import "prefix24_lib2.dart" as X;
// lib1_foo() returns value of bar() in library prefix24_lib2.
lib1_foo() => X.bar();
+7
View File
@@ -0,0 +1,7 @@
// Copyright (c) 2013, 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 prefix24_lib2;
bar() => "prefix24_lib2_bar";
+9
View File
@@ -0,0 +1,9 @@
// Copyright (c) 2013, 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 prefix24_lib3;
class X {
static bar() => "static method bar of class X";
}
+22
View File
@@ -0,0 +1,22 @@
// Copyright (c) 2013, 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 prefix24_test;
import "package:expect/expect.dart";
// Import a library that contains library prefix X.
import "prefix24_lib1.dart";
// Import a library that declares class X.
import "prefix24_lib3.dart";
// Check that the library prefix X that is used in library prefix24_lib1
// remains private to that library and does not collide with class X
// defined in (and imported from) prefix24_lib3;
main() {
Expect.equals("static method bar of class X", X.bar());
Expect.equals("prefix24_lib2_bar", lib1_foo());
}
+18
View File
@@ -0,0 +1,18 @@
// 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.
library PrefixTest.dart;
import "package:expect/expect.dart";
import "test1.dart";
class PrefixTest {
static testMain() {
Expect.equals(Prefix.getSource(), Prefix.getImport() + 1);
}
}
main() {
PrefixTest.testMain();
}
@@ -0,0 +1,36 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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.
// Type parameters can shadow a library prefix.
import "package:expect/expect.dart";
import "../library10.dart" as T;
import "../library10.dart" as lib10;
class P<T> {
test() {
}
}
main() {
new P<int>().test();
{
// Variables in the local scope hide the library prefix.
var result = 0;
result = lib10.Library10.static_fld;
Expect.equals(4, result);
}
{
// Shadowing is not an error.
var lib10 = 1;
Expect.equals(2, lib10 + 1);
}
}
+38
View File
@@ -0,0 +1,38 @@
// 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.
// Type parameters can shadow a library prefix.
import "package:expect/expect.dart";
import "../library10.dart" as T;
import "../library10.dart" as lib10;
class P<T> {
test() {
new T.Library10(10);
// ^
// [cfe] Method not found: 'T.Library10'.
}
}
main() {
new P<int>().test();
{
// Variables in the local scope hide the library prefix.
var lib10 = 0;
var result = 0;
result = lib10.Library10.static_fld;
// ^^^^^^^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
// [cfe] The getter 'Library10' isn't defined for the class 'int'.
Expect.equals(4, result);
}
{
// Shadowing is not an error.
var lib10 = 1;
Expect.equals(2, lib10 + 1);
}
}
+19
View File
@@ -0,0 +1,19 @@
// 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.
library PrefixTest1.dart;
import "test2.dart" as prefix;
class Prefix {
static const int foo = 43;
static getSource() {
return foo;
}
static getImport() {
return prefix.Prefix.foo;
}
}
+9
View File
@@ -0,0 +1,9 @@
// 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.
library PrefixTest2.dart;
class Prefix {
static const int foo = 42;
}
@@ -0,0 +1,14 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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 "../library10.dart";
main() {
// Library prefixes in the imported libraries should not be visible here.
}
@@ -0,0 +1,20 @@
// 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 "../library10.dart";
main() {
// Library prefixes in the imported libraries should not be visible here.
new lib11.Library11(1);
// ^^^^^^^^^^^^^^^
// [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
// [cfe] Method not found: 'lib11.Library11'.
lib11.Library11.static_func();
//^^^^^
// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'lib11'.
lib11.Library11.static_fld;
//^^^^^
// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'lib11'.
}
@@ -0,0 +1,18 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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.
// Symbols in libraries imported by the prefixed library should not be visible.
import "../library12.dart" as lib12;
main() {
// Class should not be visible.
// Variable should not be visible.
}
@@ -0,0 +1,21 @@
// 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.
// Symbols in libraries imported by the prefixed library should not be visible.
import "../library12.dart" as lib12;
main() {
// Class should not be visible.
new lib12.Library11(1);
// ^^^^^^^^^
// [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
// [cfe] Method not found: 'Library11'.
// Variable should not be visible.
lib12.top_level11;
// ^^^^^^^^^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_PREFIXED_NAME
// [cfe] Getter not found: 'top_level11'.
}
@@ -0,0 +1,32 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2015, 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.
// Validate the following spec text from section 16.14.3 (Unqualified
// invocation):
// An unqualifiedfunction invocation i has the form
// id(a1, ..., an, xn+1 : an+1, ..., xn+k : an+k),
// where id is an identifier.
// If there exists a lexically visible declaration named id, let fid be the
// innermost such declaration. Then:
// - If fid is a prefix object, a compile-time error occurs.
import "empty_library.dart" as p;
class Base {
void p() {}
}
class Derived extends Base {
void f() {
}
}
main() {
new Derived().f();
}
@@ -0,0 +1,35 @@
// Copyright (c) 2015, 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.
// Validate the following spec text from section 16.14.3 (Unqualified
// invocation):
// An unqualifiedfunction invocation i has the form
// id(a1, ..., an, xn+1 : an+1, ..., xn+k : an+k),
// where id is an identifier.
// If there exists a lexically visible declaration named id, let fid be the
// innermost such declaration. Then:
// - If fid is a prefix object, a compile-time error occurs.
import "empty_library.dart" as p;
class Base {
void p() {}
}
class Derived extends Base {
void f() {
p();
// ^
// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
// [cfe] A prefix can't be used as an expression.
}
}
main() {
new Derived().f();
p();
//^
// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
// [cfe] A prefix can't be used as an expression.
}
@@ -0,0 +1,22 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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.
// Unresolved symbols should be reported as an error.
import "../library12.dart" as lib12;
class Subclass
{}
class Implementer
{}
main() {
new Subclass();
new Implementer();
}
@@ -0,0 +1,25 @@
// 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.
// Unresolved symbols should be reported as an error.
import "../library12.dart" as lib12;
class Subclass
extends lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
// [cfe] Type 'lib12.Library13' not found.
{}
class Implementer
implements lib12.Library13
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
// [cfe] Type 'lib12.Library13' not found.
{}
main() {
new Subclass();
new Implementer();
}
@@ -0,0 +1,12 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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 "../library10.dart" as lib10;
// Top level variables cannot shadow library prefixes, they should collide.
main() {}
@@ -0,0 +1,13 @@
// 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 "../library10.dart" as lib10;
// ^
// [cfe] 'lib10' is already declared in this scope.
// Top level variables cannot shadow library prefixes, they should collide.
var lib10;
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER
main() {}