Revert "Enable visibleForTesting on unnamed constructors"

This reverts commit de7ad46797.

Reason for revert: breaking for google3; need to discuss how to land this kind of change.

Original change's description:
> Enable visibleForTesting on unnamed constructors
> 
> Fixes #37936
> 
> Change-Id: I99023b66d7d53922edecfbab7be41d4c4145ec15
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114591
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

TBR=brianwilkerson@google.com,srawlins@google.com

Change-Id: I9d3688b4dcdff92f94b83e1e557a488abfd963cb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116782
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
This commit is contained in:
David Morgan 2019-09-12 07:34:49 +00:00 committed by commit-bot@chromium.org
parent e6887536aa
commit 60ca2b840d
3 changed files with 3 additions and 61 deletions

View file

@ -7916,16 +7916,7 @@ class _InvalidAccessVerifier {
return;
}
// This is the same logic used in [checkForDeprecatedMemberUseAtIdentifier]
// to avoid reporting an error twice for named constructors.
AstNode parent = identifier.parent;
if (parent is ConstructorName && identical(identifier, parent.name)) {
return;
}
AstNode grandparent = parent?.parent;
Element element = grandparent is ConstructorName
? grandparent.staticElement
: identifier.staticElement;
Element element = identifier.staticElement;
if (element == null || _inCurrentLibrary(element)) {
return;
}

View file

@ -34,32 +34,7 @@ class _VisibleForTemplate {
''');
}
test_unnamedConstructor() async {
addAngularMetaPackage();
newFile('/lib1.dart', content: r'''
import 'package:angular_meta/angular_meta.dart';
class A {
int _x;
@visibleForTemplate
A(this._x);
}
''');
newFile('/lib2.dart', content: r'''
import 'lib1.dart';
void main() {
new A(0);
}
''');
await _resolveTestFile('/lib1.dart');
await _resolveTestFile('/lib2.dart');
assertTestErrorsWithCodes(
[HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER]);
}
test_namedConstructor() async {
test_constructor() async {
addAngularMetaPackage();
newFile('/lib1.dart', content: r'''
import 'package:angular_meta/angular_meta.dart';

View file

@ -25,31 +25,7 @@ class InvalidUseOfVisibleForTestingMemberTest extends DriverResolutionTest
..contextFeatures = new FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_unnamedConstructor() async {
addMetaPackage();
newFile('/lib1.dart', content: r'''
import 'package:meta/meta.dart';
class A {
int _x;
@visibleForTesting
A(this._x);
}
''');
newFile('/lib2.dart', content: r'''
import 'lib1.dart';
void main() {
new A(0);
}
''');
await _resolveTestFile('/lib1.dart');
await _resolveTestFile('/lib2.dart');
assertTestErrorsWithCodes(
[HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER]);
}
test_namedConstructor() async {
test_constructor() async {
addMetaPackage();
newFile('/lib1.dart', content: r'''
import 'package:meta/meta.dart';