Skip to content

Commit

Permalink
Fix bug and get ready to release. (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey committed Nov 22, 2017
1 parent 25571e3 commit 8d2ee42
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 2.2.0-dev
## 2.2.0

* Imports are prefixed with `_i1` rather than `_1` which satisfies the lint
`lowercase_with_underscores`. While not a strictly breaking change you may
Expand Down Expand Up @@ -31,6 +31,27 @@ void main() {

* `literalList` accepts an `Iterable` argument.

* Fixed an NPE when a method had a return type of a `FunctionType`:

```dart
void main() {
test('should create a method with a function type return type', () {
expect(
new Method((b) => b
..name = 'foo'
..returns = new FunctionType((b) => b
..returnType = refer('String')
..requiredParameters.addAll([
refer('int'),
]))),
equalsDart(r'''
String Function(int) foo();
'''),
);
});
}
```

## 2.1.0

We now require the Dart 2.0-dev branch SDK (`>= 2.0.0-dev`).
Expand Down
2 changes: 1 addition & 1 deletion lib/src/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class DartEmitter extends Object
output.write('static ');
}
if (spec.returns != null) {
spec.returns.type.accept(this, output);
spec.returns.accept(this, output);
output.write(' ');
}
if (spec.type == MethodType.getter) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: code_builder
version: 2.2.0-dev
version: 2.2.0
description: A fluent API for generating Dart code
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/code_builder
Expand Down
15 changes: 15 additions & 0 deletions test/specs/method_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ void main() {
);
});

test('should create a method with a function type return type', () {
expect(
new Method((b) => b
..name = 'foo'
..returns = new FunctionType((b) => b
..returnType = refer('String')
..requiredParameters.addAll([
refer('int'),
]))),
equalsDart(r'''
String Function(int) foo();
'''),
);
});

test('should create a method with generic types', () {
expect(
new Method((b) => b
Expand Down

0 comments on commit 8d2ee42

Please sign in to comment.