dart-sdk/tests/language_2/prefix_shadow_test.dart
Bob Nystrom bed71b7776 Migrate and clean up the prefix negative tests.
Since there were already non-negative tests with the same numbers, I
gave them meaningful names.

Merged a couple of tests into the same file when it made sense since
multitests let us do that.

Deleted prefix1_negative_test, because it essentially tested only that
a random identifier does not resolve, which is not particularly related
to prefixes.

Change-Id: I91718f6df5126f123d9a8ea3abbc6898797db2db
Reviewed-on: https://dart-review.googlesource.com/52985
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-02 16:05:25 +00:00

34 lines
787 B
Dart

// 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); //# 01: compile-time error
}
}
main() {
new P<int>().test();
{
// Variables in the local scope hide the library prefix.
var lib10 = 0; //# 02: compile-time error
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);
}
}