[dart2js] Ensure generic local functions are marked as potentially

needing type arguments.

Change-Id: I50831df2530395b9ec3562be171422b0b6455335
Bug: https://github.com/dart-lang/sdk/issues/42501
Fixes: https://github.com/dart-lang/sdk/issues/42501
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152606
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
Mayank Patke 2020-06-26 21:27:38 +00:00 committed by commit-bot@chromium.org
parent 4b93c8aabd
commit e8daaefabf
5 changed files with 43 additions and 8 deletions

View file

@ -1071,6 +1071,9 @@ class RuntimeTypesNeedBuilderImpl implements RuntimeTypesNeedBuilder {
// TODO(johnniwinther): Use register generic instantiations
// instead.
assumeInstantiations: _genericInstantiations.isNotEmpty)) {
if (functionType.typeVariables.isNotEmpty) {
potentiallyNeedTypeArguments(function);
}
functionType.forEachTypeVariable((TypeVariableType typeVariable) {
Entity typeDeclaration = typeVariable.element.typeDeclaration;
if (!processedEntities.contains(typeDeclaration)) {

View file

@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
method1() {
/*spec.direct,explicit=[local.T*],needsArgs,needsSignature*/
/*prod.needsSignature*/
/*prod.needsArgs,needsSignature*/
T local<T>(T t) => t;
return local;
}

View file

@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
class Class1 {
method1() {
/*needsSignature*/
/*needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
num local<T>(num n) => null;
return local;
}
@ -19,7 +19,7 @@ class Class1 {
}
method3() {
/*needsSignature*/
/*needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
int local<T>(num n) => null;
return local;
}
@ -75,13 +75,13 @@ method9<T>() {
method10() {
/*spec.direct,explicit=[local.T*],needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
/*prod.needsSignature*/
/*prod.needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
num local<T>(T n) => null;
return local;
}
method11() {
/*needsSignature*/
/*needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
T local<T>(num n) => null;
return local;
}
@ -93,20 +93,20 @@ method12() {
}
num Function(num) method13() {
/*needsSignature*/
/*needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
num local<T>(num n) => null;
return local;
}
num Function(num) method14() {
/*spec.direct,explicit=[local.T*],needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
/*prod.needsSignature*/
/*prod.needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
num local<T>(T n) => null;
return local;
}
num Function(num) method15() {
/*needsSignature*/
/*needsArgs,needsInst=[<dynamic>,<num*>,<num*>],needsSignature*/
T local<T>(num n) => null;
return local;
}

View file

@ -0,0 +1,16 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
typedef F = num? Function();
F foo() {
T? local<T>() => null;
return local;
}
void main() {
Expect.type<F>(foo());
}

View file

@ -0,0 +1,16 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
typedef F = num Function();
F foo() {
T local<T>() => null;
return local;
}
void main() {
Expect.type<F>(foo());
}