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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1374813002: fix inference of `hashCode` with library prefix (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/context/context.dart' as newContext; 9 import 'package:analyzer/src/context/context.dart' as newContext;
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 13935 matching lines...) Expand 10 before | Expand all | Expand 10 after
13946 dynamic obj; 13946 dynamic obj;
13947 obj..$name()..$name(); // marker 13947 obj..$name()..$name(); // marker
13948 }'''; 13948 }''';
13949 SimpleIdentifier methodName = _findMarkedIdentifier(code, "(); // marker"); 13949 SimpleIdentifier methodName = _findMarkedIdentifier(code, "(); // marker");
13950 MethodInvocation methodInvoke = methodName.parent; 13950 MethodInvocation methodInvoke = methodName.parent;
13951 13951
13952 expect(methodInvoke.staticType, typeProvider.dynamicType); 13952 expect(methodInvoke.staticType, typeProvider.dynamicType);
13953 expect(methodInvoke.realTarget.staticType, typeProvider.dynamicType); 13953 expect(methodInvoke.realTarget.staticType, typeProvider.dynamicType);
13954 } 13954 }
13955 13955
13956
13957 void test_objectAccessInference_disabled_for_local_getter() {
13958 String name = 'hashCode';
13959 String code = '''
13960 dynamic get $name => null;
13961 main() {
13962 $name; // marker
13963 }''';
13964
13965 SimpleIdentifier getter = _findMarkedIdentifier(code, "; // marker");
13966 expect(getter.staticType, typeProvider.dynamicType);
13967 }
13968
13969 void test_objectAccessInference_disabled_for_library_prefix() {
13970 String name = 'hashCode';
13971 addNamedSource('/helper.dart', '''
13972 library helper;
13973 dynamic get $name => 42;
13974 ''');
13975 String code = '''
13976 import 'helper.dart' as helper;
13977 main() {
13978 helper.$name; // marker
13979 }''';
13980
13981 SimpleIdentifier id = _findMarkedIdentifier(code, "; // marker");
13982 PrefixedIdentifier prefixedId = id.parent;
13983 expect(id.staticType, typeProvider.dynamicType);
13984 expect(prefixedId.staticType, typeProvider.dynamicType);
13985 }
13986
13987 void test_objectAccessInference_enabled_for_cascades() {
13988 String name = 'hashCode';
13989 String code = '''
13990 main() {
13991 dynamic obj;
13992 obj..$name..$name; // marker
13993 }''';
13994 PropertyAccess access = _findMarkedIdentifier(code, "; // marker").parent;
13995 expect(access.staticType, typeProvider.dynamicType);
13996 expect(access.realTarget.staticType, typeProvider.dynamicType);
13997 }
13998
13956 void test_propagatedReturnType_localFunction() { 13999 void test_propagatedReturnType_localFunction() {
13957 String code = r''' 14000 String code = r'''
13958 main() { 14001 main() {
13959 f() => 42; 14002 f() => 42;
13960 var v = f(); 14003 var v = f();
13961 }'''; 14004 }''';
13962 _assertPropagatedAssignedType( 14005 _assertPropagatedAssignedType(
13963 code, typeProvider.dynamicType, typeProvider.intType); 14006 code, typeProvider.dynamicType, typeProvider.intType);
13964 } 14007 }
13965 14008
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
14783 // check propagated type 14826 // check propagated type
14784 FunctionType propagatedType = node.propagatedType as FunctionType; 14827 FunctionType propagatedType = node.propagatedType as FunctionType;
14785 expect(propagatedType.returnType, test.typeProvider.stringType); 14828 expect(propagatedType.returnType, test.typeProvider.stringType);
14786 } on AnalysisException catch (e, stackTrace) { 14829 } on AnalysisException catch (e, stackTrace) {
14787 thrownException[0] = new CaughtException(e, stackTrace); 14830 thrownException[0] = new CaughtException(e, stackTrace);
14788 } 14831 }
14789 } 14832 }
14790 return null; 14833 return null;
14791 } 14834 }
14792 } 14835 }
OLDNEW
« 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