blob: 56a648279133c435db93ba0414c79360f9216aee [file] [log] [blame]
// Copyright (c) 2020, 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:analyzer/src/error/codes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(UnqualifiedReferenceToNonLocalStaticMemberTest);
});
}
@reflectiveTest
class UnqualifiedReferenceToNonLocalStaticMemberTest
extends PubPackageResolutionTest {
test_getter() async {
await assertErrorsInCode(r'''
class A {
static int get a => 0;
}
class B extends A {
int b() {
return a;
}
}
''', [
error(
CompileTimeErrorCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
80,
1),
]);
}
test_getter_invokeTarget() async {
await assertErrorsInCode(r'''
class A {
static int foo;
}
class B extends A {
static bar() {
foo.abs();
}
}
''', [
error(
CompileTimeErrorCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
72,
3),
]);
}
test_setter() async {
await assertErrorsInCode(r'''
class A {
static set a(x) {}
}
class B extends A {
b(y) {
a = y;
}
}
''', [
error(
CompileTimeErrorCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
66,
1),
]);
}
}