Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-alpha+8

- Fix an import scoping bug in `return` statements and named constructor invocations.

## 1.0.0-alpha+7

- Make use of new analyzer API in preparation for analyzer version 0.30.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/builders/expression/return.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class _AsReturn extends TopLevelMixin implements StatementBuilder {
Statement buildStatement([Scope scope]) {
return astFactory.returnStatement(
$return,
_value.buildExpression(),
_value.buildExpression(scope),
$semicolon,
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/builders/method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class _NormalConstructorBuilder extends Object
null,
null,
null,
returnType.buildType().name,
returnType.buildType(scope).name,
_name != null ? $period : null,
_name != null ? stringIdentifier(_name) : null,
buildParameterList(scope),
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: 1.0.0-alpha+7
version: 1.0.0-alpha+8
description: A fluent API for generating Dart code
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/code_builder
Expand Down
10 changes: 9 additions & 1 deletion test/e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ void main() {
reference('_module').invoke('getDep1', []),
reference('_module').invoke('getDep2', []),
]),
)..addAnnotation(lib$core.override)));
)..addAnnotation(lib$core.override))
..addMethod(new MethodBuilder(
'instantiateAndReturnNamedThing',
returnType: thingRef,
)..addStatement(thingRef.namedNewInstance('named', []).asReturn())));
expect(
lib,
equalsSource(
Expand All @@ -99,6 +103,10 @@ void main() {

@override
_i2.Thing getThing() => new _i2.Thing(_module.getDep1(), _module.getDep2());

_i2.Thing instantiateAndReturnNamedThing() {
return new _i2.Thing.named();
}
}
''',
pretty: true,
Expand Down