| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 import 'dart:core'; | |
| 6 | |
| 7 void throwString() { | |
| 8 throw 'hello world!'; // LINT | |
| 9 } | |
| 10 | |
| 11 void throwNull() { | |
| 12 throw null; // LINT | |
| 13 } | |
| 14 | |
| 15 void throwNumber() { | |
| 16 throw 7; // LINT | |
| 17 } | |
| 18 | |
| 19 void throwObject() { | |
| 20 throw new Object(); // LINT | |
| 21 } | |
| 22 | |
| 23 void throwError() { | |
| 24 throw new Error(); // OK | |
| 25 } | |
| 26 | |
| 27 void throwDynamicPrebuiltError() { | |
| 28 var error = new Error(); | |
| 29 throw error; // OK | |
| 30 } | |
| 31 | |
| 32 void throwStaticPrebuiltError() { | |
| 33 Error error = new Error(); | |
| 34 throw error; // OK | |
| 35 } | |
| 36 | |
| 37 void throwArgumentError() { | |
| 38 Error error = new ArgumentError('oh!'); | |
| 39 throw error; // OK | |
| 40 } | |
| 41 | |
| 42 void throwException() { | |
| 43 Exception exception = new Exception('oh!'); | |
| 44 throw exception; // OK | |
| 45 } | |
| 46 | |
| 47 void throwStringFromFunction() { | |
| 48 throw returnString(); // LINT | |
| 49 } | |
| 50 | |
| 51 String returnString() => 'string!'; | |
| 52 | |
| 53 void throwExceptionFromFunction() { | |
| 54 throw returnException(); | |
| 55 } | |
| 56 | |
| 57 Exception returnException() => new Exception('oh!'); | |
| 58 | |
| 59 // TODO: Even though in the test this does not get linted, it does while | |
| 60 // analyzing the SDK code. Find out why. | |
| 61 dynamic noSuchMethod(Invocation invocation) { | |
| 62 throw new NoSuchMethodError( | |
| 63 new Object(), | |
| 64 invocation.memberName, | |
| 65 invocation.positionalArguments, | |
| 66 invocation.namedArguments); | |
| 67 } | |
| 68 | |
| 69 class E extends Object with Exception { | |
| 70 static throws() { | |
| 71 throw new E(); // OK | |
| 72 } | |
| 73 } | |
| OLD | NEW |