OLD | NEW |
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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 /** | 7 /** |
8 * Categorizes `noSuchMethod` implementations. | 8 * Categorizes `noSuchMethod` implementations. |
9 * | 9 * |
10 * If user code includes `noSuchMethod` implementations, type inference is | 10 * If user code includes `noSuchMethod` implementations, type inference is |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 /// subcategories: C1, those that have no return type, and C2, those | 75 /// subcategories: C1, those that have no return type, and C2, those |
76 /// that have a return type. | 76 /// that have a return type. |
77 void onTypeInferenceComplete() { | 77 void onTypeInferenceComplete() { |
78 otherImpls.forEach(_subcategorizeOther); | 78 otherImpls.forEach(_subcategorizeOther); |
79 } | 79 } |
80 | 80 |
81 /// Emits a diagnostic | 81 /// Emits a diagnostic |
82 void emitDiagnostic() { | 82 void emitDiagnostic() { |
83 throwingImpls.forEach((e) { | 83 throwingImpls.forEach((e) { |
84 if (!_hasForwardingSyntax(e)) { | 84 if (!_hasForwardingSyntax(e)) { |
85 _compiler.reportHint(e, | 85 _compiler.reportHintMessage( |
86 MessageKind.DIRECTLY_THROWING_NSM); | 86 e, MessageKind.DIRECTLY_THROWING_NSM); |
87 } | 87 } |
88 }); | 88 }); |
89 complexNoReturnImpls.forEach((e) { | 89 complexNoReturnImpls.forEach((e) { |
90 if (!_hasForwardingSyntax(e)) { | 90 if (!_hasForwardingSyntax(e)) { |
91 _compiler.reportHint(e, | 91 _compiler.reportHintMessage( |
92 MessageKind.COMPLEX_THROWING_NSM); | 92 e, MessageKind.COMPLEX_THROWING_NSM); |
93 } | 93 } |
94 }); | 94 }); |
95 complexReturningImpls.forEach((e) { | 95 complexReturningImpls.forEach((e) { |
96 if (!_hasForwardingSyntax(e)) { | 96 if (!_hasForwardingSyntax(e)) { |
97 _compiler.reportHint(e, | 97 _compiler.reportHintMessage( |
98 MessageKind.COMPLEX_RETURNING_NSM); | 98 e, MessageKind.COMPLEX_RETURNING_NSM); |
99 } | 99 } |
100 }); | 100 }); |
101 } | 101 } |
102 | 102 |
103 /// Returns [true] if the given element is a complex [noSuchMethod] | 103 /// Returns [true] if the given element is a complex [noSuchMethod] |
104 /// implementation. An implementation is complex if it falls into | 104 /// implementation. An implementation is complex if it falls into |
105 /// category C, as described above. | 105 /// category C, as described above. |
106 bool isComplex(FunctionElement element) { | 106 bool isComplex(FunctionElement element) { |
107 assert(element.name == Identifiers.noSuchMethod_); | 107 assert(element.name == Identifiers.noSuchMethod_); |
108 return otherImpls.contains(element); | 108 return otherImpls.contains(element); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (body.statements.nodes.head is ExpressionStatement) { | 216 if (body.statements.nodes.head is ExpressionStatement) { |
217 ExpressionStatement stmt = body.statements.nodes.head; | 217 ExpressionStatement stmt = body.statements.nodes.head; |
218 return stmt.expression is Throw; | 218 return stmt.expression is Throw; |
219 } | 219 } |
220 } | 220 } |
221 return false; | 221 return false; |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 enum NsmCategory { DEFAULT, THROWING, OTHER } | 225 enum NsmCategory { DEFAULT, THROWING, OTHER } |
OLD | NEW |