Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1515)

Unified Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1374773003: fix inference of object members on library prefix (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix cascades Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/resolver_test.dart
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 556e4187017760bd7a352bb4a6468f587ad69f56..8935837cceedf78ecb964ecc77e284d10e10984c 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -12172,20 +12172,6 @@ main() {
code, typeProvider.dynamicType, typeProvider.intType);
}
- void test_localVariableInference_declaredType_disabled_for_toString() {
- String name = 'toString';
- String code = '''
-main() {
- dynamic $name = () => null;
- $name(); // marker
-}''';
- SimpleIdentifier identifier = _findMarkedIdentifier(code, "$name = ");
- expect(identifier.staticType, typeProvider.dynamicType);
- SimpleIdentifier call = _findMarkedIdentifier(code, "(); // marker");
- expect(call.staticType, typeProvider.dynamicType);
- expect((call.parent as Expression).staticType, typeProvider.dynamicType);
- }
-
void test_localVariableInference_noInitializer_disabled() {
String code = r'''
main() {
@@ -13920,6 +13906,53 @@ f1(x) {
typeProvider.stringType);
}
+ void test_objectMethodInference_disabled_for_local_function() {
Jennifer Messerly 2015/09/28 21:15:47 I noticed these tests seemed to be in the wrong pl
Brian Wilkerson 2015/09/28 21:24:17 That's fine, but just FYI: we always format and so
Jennifer Messerly 2015/09/28 21:39:44 sounds good. I renamed them too (old name was loca
+ String name = 'toString';
+ String code = '''
+main() {
+ dynamic $name = () => null;
+ $name(); // marker
+}''';
+ SimpleIdentifier identifier = _findMarkedIdentifier(code, "$name = ");
+ expect(identifier.staticType, typeProvider.dynamicType);
+
+ SimpleIdentifier methodName = _findMarkedIdentifier(code, "(); // marker");
+ MethodInvocation methodInvoke = methodName.parent;
+ expect(methodName.staticType, typeProvider.dynamicType);
+ expect(methodInvoke.staticType, typeProvider.dynamicType);
+ }
+
+ void test_objectMethodInference_disabled_for_library_prefix() {
+ String name = 'toString';
+ addNamedSource('/helper.dart', '''
+library helper;
+dynamic $name = (int x) => x + 42');
+''');
+ String code = '''
+import 'helper.dart' as helper;
+main() {
+ helper.$name(); // marker
+}''';
+ SimpleIdentifier methodName = _findMarkedIdentifier(code, "(); // marker");
+ MethodInvocation methodInvoke = methodName.parent;
+ expect(methodName.staticType, null, reason: 'library prefix has no type');
+ expect(methodInvoke.staticType, typeProvider.dynamicType);
+ }
+
+ void test_objectMethodInference_enabled_for_cascades() {
+ String name = 'toString';
+ String code = '''
+main() {
+ dynamic obj;
+ obj..$name()..$name(); // marker
+}''';
+ SimpleIdentifier methodName = _findMarkedIdentifier(code, "(); // marker");
+ MethodInvocation methodInvoke = methodName.parent;
+
+ expect(methodInvoke.staticType, typeProvider.dynamicType);
+ expect(methodInvoke.realTarget.staticType, typeProvider.dynamicType);
+ }
+
void test_propagatedReturnType_localFunction() {
String code = r'''
main() {
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698