Skip to content

Commit 13b57ce

Browse files
author
Jennifer Messerly
committed
fix #30912, record scope dependencies on unused typedef type arguments
Change-Id: Ic859620fb4ff7f9965b46849aa96eb74dfe59ccb Reviewed-on: https://dart-review.googlesource.com/9125 Reviewed-by: Vijay Menon <[email protected]>
1 parent 44dca2e commit 13b57ce

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

pkg/dev_compiler/lib/src/compiler/type_utilities.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Set<TypeParameterElement> freeTypeParameters(DartType t) {
1616
if (t is TypeParameterType) {
1717
result.add(t.element);
1818
} else if (t is FunctionType) {
19+
// Visit type arguments of typedefs, because we use these when we're
20+
// emitting the type.
21+
if (t.name != '' && t.name != null) {
22+
t.typeArguments.forEach(find);
23+
}
1924
find(t.returnType);
2025
t.parameters.forEach((p) => find(p.type));
2126
t.typeFormals.forEach((p) => find(p.bound));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2017, 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 'package:expect/expect.dart';
6+
7+
class Foo {}
8+
9+
class Bar {}
10+
11+
typedef Type Func<S extends Foo, T>(T s);
12+
13+
class Baz<S extends Foo, T extends Bar> {
14+
Func<S, Bar> func;
15+
}
16+
17+
/// Regression test for https://github.com/dart-lang/sdk/issues/30912
18+
void main() {
19+
dynamic baz = new Baz();
20+
Expect.isNull(baz.func);
21+
baz.func = (Bar b) => b.runtimeType;
22+
Expect.equals(baz.func(new Bar()), Bar);
23+
}

0 commit comments

Comments
 (0)