Skip to content

Commit

Permalink
Fix regression in splitting type annotations with library prefixes. (#…
Browse files Browse the repository at this point in the history
…1250)

* Fix regression in splitting type annotations with library prefixes.

Fix #1249.

* Require Dart 3.0.

* Stop testing on 2.19 and move to 3.0.
  • Loading branch information
munificent authored Aug 21, 2023
1 parent 0903be1 commit 4c58ddf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [2.19.0, dev]
sdk: [3.0.0, dev]
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [2.19.0, dev]
sdk: [3.0.0, dev]
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2.3.3-dev

* Remove support for `inline class` since that syntax has changed.
* Fix regression in splitting type annotations with library prefixes (#1249).

## 2.3.2

Expand Down
13 changes: 5 additions & 8 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2251,22 +2251,19 @@ class SourceVisitor extends ThrowingAstVisitor {

@override
void visitNamedType(NamedType node) {
var importPrefix = node.importPrefix;
if (importPrefix != null) {
if (node.importPrefix case var importPrefix?) {
builder.startSpan();

token(importPrefix.name);
soloZeroSplit();
token(importPrefix.period);
token(node.name2);
builder.endSpan();
} else {
token(node.name2);
}

token(node.name2);
visit(node.typeArguments);
token(node.question);

if (importPrefix != null) {
builder.endSpan();
}
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: >-
Provides an API and a CLI tool.
repository: https://github.com/dart-lang/dart_style
environment:
sdk: ">=2.19.0 <3.0.0"
sdk: "^3.0.0"

dependencies:
analyzer: '>=5.12.0 <7.0.0'
Expand Down
6 changes: 3 additions & 3 deletions test/regression/0100/0108.unit
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ async.Future<List<dom.StyleElement>> call(String tag, List<String> cssUrls, {Typ
DDC$RT.type((Iterable<Future<dynamic>> _) {}), key: "Cast failed: package:angular/core_dom/component_css_loader.dart:17:25"))),
DDC$RT.type((Future<List<StyleElement>> _) {}), key: "Cast failed: package:angular/core_dom/component_css_loader.dart:17:7"));
<<<
async.Future<List<dom.StyleElement>> call(String tag, List<String> cssUrls, {Type type}) =>
async.Future<List<dom.StyleElement>> call(String tag, List<String> cssUrls,
{Type type}) =>
(DDC$RT.cast(
async.Future.wait((DDC$RT.cast(
cssUrls.map((url) => _styleElement(
tag,
(DDC$RT.cast(url, String,
key: "Cast failed: package:angular/core_dom/component_css_loader.dart:17:65")),
(DDC$RT.cast(url, String, key: "Cast failed: package:angular/core_dom/component_css_loader.dart:17:65")),
type)),
DDC$RT.type((Iterable<Future<dynamic>> _) {}),
key: "Cast failed: package:angular/core_dom/component_css_loader.dart:17:25"))),
Expand Down
13 changes: 13 additions & 0 deletions test/regression/1200/1249.unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
>>>
class C {
late final _callocPtr = _lookup<
ffi
.NativeFunction<ffi_Pointer_ffi_Void_ Function(ffi_Size__ffi_Size)>>(
'calloc');
}
<<<
class C {
late final _callocPtr = _lookup<
ffi.NativeFunction<
ffi_Pointer_ffi_Void_ Function(ffi_Size__ffi_Size)>>('calloc');
}

0 comments on commit 4c58ddf

Please sign in to comment.