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

Side by Side Diff: lib/runtime/dart_runtime.dart

Issue 962213003: fix analysis messages (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | lib/src/testing.dart » ('j') | test/checker/inferred_type_test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 ddc.runtime.dart_runtime; 5 library ddc.runtime.dart_runtime;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 8
9 import 'package:dev_compiler/config.dart'; 9 import 'package:dev_compiler/config.dart';
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Ignore named parameters - these cannot be passed positionally. 121 // Ignore named parameters - these cannot be passed positionally.
122 } else if (parameter.isOptional) { 122 } else if (parameter.isOptional) {
123 optionalPositional++; 123 optionalPositional++;
124 } else { 124 } else {
125 normal++; 125 normal++;
126 } 126 }
127 } 127 }
128 return new Arity._internal(normal, optionalPositional); 128 return new Arity._internal(normal, optionalPositional);
129 } 129 }
130 130
131 bool _isFunctionSubType(TypeMirror t1, TypeMirror t2) { 131 bool _isFunctionSubType(TypeMirror ret1, List<ParameterMirror> params1,
132 // Function types follow the standard non-Dart rule:
133 // - contravariant on param types
134 // - covariant on return type
135 final f1 = t1 as FunctionTypeMirror;
136 final f2 = t2 as FunctionTypeMirror;
137
138 final params1 = f1.parameters;
139 final params2 = f2.parameters;
140 final ret1 = f1.returnType;
141 final ret2 = f2.returnType;
142 return _isFunctionSubTypeHelper(ret1, params1, ret2, params2);
143 }
144
145 bool _isFunctionSubTypeHelper(TypeMirror ret1, List<ParameterMirror> params1,
146 TypeMirror ret2, List<ParameterMirror> params2) { 132 TypeMirror ret2, List<ParameterMirror> params2) {
147 if (!_isSubType(ret1, ret2)) { 133 if (!_isSubType(ret1, ret2)) {
148 // Covariant return types 134 // Covariant return types
149 // Note, void (which can only appear as a return type) is effectively 135 // Note, void (which can only appear as a return type) is effectively
150 // treated as dynamic. If the base return type is void, we allow any 136 // treated as dynamic. If the base return type is void, we allow any
151 // subtype return type. 137 // subtype return type.
152 // E.g., we allow: 138 // E.g., we allow:
153 // () -> int <: () -> void 139 // () -> int <: () -> void
154 if (ret2.simpleName != const Symbol('void')) { 140 if (ret2.simpleName != const Symbol('void')) {
155 return false; 141 return false;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (call1 == null || !call1.isRegularMethod) return false; 313 if (call1 == null || !call1.isRegularMethod) return false;
328 // Class that emulate a function 314 // Class that emulate a function
329 ret1 = call1.returnType; 315 ret1 = call1.returnType;
330 params1 = call1.parameters; 316 params1 = call1.parameters;
331 } 317 }
332 318
333 // Any type that implements a call method implicitly subtypes Function. 319 // Any type that implements a call method implicitly subtypes Function.
334 if (_reflects(c2, Function)) return true; 320 if (_reflects(c2, Function)) return true;
335 321
336 // Check structural function subtyping 322 // Check structural function subtyping
337 return _isFunctionSubTypeHelper(ret1, params1, c2.returnType, c2.parameters); 323 return _isFunctionSubType(ret1, params1, c2.returnType, c2.parameters);
338 } 324 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/testing.dart » ('j') | test/checker/inferred_type_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698