I have a problem with generic methods. Just to make an example I have generated a new project in WebStorm with Angular2. I'm using dart 1.22.0-dev 10.1, but I had the problem also with dart 1.21.1. I have added a single class in the app_component.dart file:
import 'package:angular2/core.dart';
import 'package:angular2_components/angular2_components.dart';
import 'package:deleteMe/hello_dialog/hello_dialog.dart';
@Component(
selector: 'my-app',
styleUrls: const ['app_component.css'],
templateUrl: 'app_component.html',
directives: const [materialDirectives, HelloDialog],
providers: const [materialProviders],
)
class AppComponent {
// Nothing here yet. All logic is in HelloDialog.
}
class abc {
T foo<T>(T value) {
return value;
}
}
The analyzer does not throw any error, but, when I try to run the example I get the following errors from pub:
[DirectiveProcessor]:
Failed with 4 errors
Error 1: line 23, column 5 of lib\app_component.dart and parts: Expected to find ';'
T foo<T>(T value) {
^^^
Error 2: line 23, column 8 of lib\app_component.dart and parts: Expected a class member
T foo<T>(T value) {
^
Error 3: line 23, column 8 of lib\app_component.dart and parts: Unexpected token '<'
T foo<T>(T value) {
^
Error 4: line 23, column 10 of lib\app_component.dart and parts: Operator declarations must be preceeded by the keyword 'operator'
T foo<T>(T value) {
^
Build error:
Transform DirectiveProcessor on deleteMe|lib/app_component.dart threw error: Error in lib/app_component.dart and parts: Expected to find ';'
Error in lib/app_component.dart and parts: Expected a class member
Error in lib/app_component.dart and parts: Unexpected token '<'
Error in lib/app_component.dart and parts: Operator declarations must be preceeded by the keyword 'operator'
package:analyzer/analyzer.dart 116 _parseSource
package:analyzer/analyzer.dart 44 parseCompilationUnit
package:angular2/src/transform/directive_processor/rewriter.dart 31 createNgMeta.<async>
dart:async-patch/async_patch.dart 27 _asyncThenWrapperHelper.<fn>
dart:async/zone.dart 1158 _rootRunUnary
dart:async/zone.dart 1037 _CustomZone.runUnary
dart:async/future_impl.dart 131 _FutureListener.handleValue
dart:async/future_impl.dart 637 _Future._propagateToListeners.handleValueCallback
dart:async/future_impl.dart 667 _Future._propagateToListeners
dart:async/future_impl.dart 467 _Future._complete
dart:async/future_impl.dart 52 _SyncCompleter.complete
package:angular2/src/transform/common/logging.dart 27 logElapsedAsync.<async>
dart:async-patch/async_patch.dart 27 _asyncThenWrapperHelper.<fn>
dart:async/zone.dart 1158 _rootRunUnary
dart:async/zone.dart 1037 _CustomZone.runUnary
dart:async/future_impl.dart 131 _FutureListener.handleValue
dart:async/future_impl.dart 637 _Future._propagateToListeners.handleValueCallback
dart:async/future_impl.dart 667 _Future._propagateToListeners
dart:async/future_impl.dart 477 _Future._completeWithValue
dart:async/future_impl.dart 528 _Future._asyncComplete.<fn>
dart:async/zone.dart 1150 _rootRun
dart:async/zone.dart 1026 _CustomZone.run
dart:async/zone.dart 953 _CustomZone.bindCallback.<fn>
dart:async/schedule_microtask.dart 41 _microtaskLoop
dart:async/schedule_microtask.dart 50 _startMicrotaskLoop
dart:isolate-patch/isolate_patch.dart 96 _runPendingImmediateCallback
dart:isolate-patch/isolate_patch.dart 149 _RawReceivePortImpl._handleMessage
package:analyzer/analyzer.dart 116 _parseSource
package:analyzer/analyzer.dart 44 parseCompilationUnit
package:angular2/src/transform/directive_processor/rewriter.dart 31 createNgMeta.<async>
dart:async _SyncCompleter.complete
package:angular2/src/transform/common/logging.dart 27 logElapsedAsync.<async>