mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:27:39 +00:00
Issue 37608. Use instantiated FunctionType for tear-off(s).
I was working of switching runtimeTypeMatch() to purely typeSystem.isSubtypeOf(), without working around dartbug.com/35993 and dartbug.com/33441, but bots were failing. I think that was because of this issue with incorrect tear-off types. We have to fix it before switching to less generous TypeSystem. R=brianwilkerson@google.com, paulberry@google.com Bug: https://github.com/dart-lang/sdk/issues/37608 Change-Id: I1f5dfc5e86553a352d72e772e791978772fe8fa4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118379 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
dbefc6c165
commit
acac9ab11b
|
@ -1618,7 +1618,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
|
|||
/// Return the constant value of the static constant represented by the given
|
||||
/// [element]. The [node] is the node to be used if an error needs to be
|
||||
/// reported.
|
||||
DartObjectImpl _getConstantValue(AstNode node, Element element) {
|
||||
DartObjectImpl _getConstantValue(Expression node, Element element) {
|
||||
Element variableElement =
|
||||
element is PropertyAccessorElement ? element.variable : element;
|
||||
if (variableElement is VariableElementImpl) {
|
||||
|
@ -1634,11 +1634,8 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
|
|||
} else if (variableElement is ExecutableElement) {
|
||||
ExecutableElement function = element;
|
||||
if (function.isStatic) {
|
||||
ParameterizedType functionType = function.type;
|
||||
if (functionType == null) {
|
||||
functionType = _typeProvider.functionType;
|
||||
}
|
||||
return new DartObjectImpl(functionType, new FunctionState(function));
|
||||
var functionType = node.staticType;
|
||||
return DartObjectImpl(functionType, FunctionState(function));
|
||||
}
|
||||
} else if (variableElement is ClassElement) {
|
||||
var type = variableElement.instantiate(
|
||||
|
|
|
@ -89,6 +89,20 @@ class ConstantAstCloner extends AstCloner {
|
|||
return literal;
|
||||
}
|
||||
|
||||
@override
|
||||
PrefixedIdentifier visitPrefixedIdentifier(PrefixedIdentifier node) {
|
||||
PrefixedIdentifierImpl copy = super.visitPrefixedIdentifier(node);
|
||||
copy.staticType = node.staticType;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@override
|
||||
PropertyAccess visitPropertyAccess(PropertyAccess node) {
|
||||
PropertyAccessImpl copy = super.visitPropertyAccess(node);
|
||||
copy.staticType = node.staticType;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@override
|
||||
RedirectingConstructorInvocation visitRedirectingConstructorInvocation(
|
||||
RedirectingConstructorInvocation node) {
|
||||
|
@ -110,9 +124,11 @@ class ConstantAstCloner extends AstCloner {
|
|||
|
||||
@override
|
||||
SimpleIdentifier visitSimpleIdentifier(SimpleIdentifier node) {
|
||||
SimpleIdentifier identifier = super.visitSimpleIdentifier(node);
|
||||
identifier.staticElement = node.staticElement;
|
||||
return identifier;
|
||||
SimpleIdentifierImpl copy = super.visitSimpleIdentifier(node);
|
||||
copy.staticElement = node.staticElement;
|
||||
copy.staticType = node.staticType;
|
||||
copy.tearOffTypeArgumentTypes = node.tearOffTypeArgumentTypes;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -88,7 +88,7 @@ class ConstantsDataExtractor extends AstDataExtractor<String> {
|
|||
}
|
||||
} else if (type is FunctionType) {
|
||||
var element = value.toFunctionValue();
|
||||
return 'Function(${element.name})';
|
||||
return 'Function(${element.name},type=${value.type})';
|
||||
}
|
||||
throw UnimplementedError('_stringify for type $type');
|
||||
}
|
||||
|
|
|
@ -14,15 +14,16 @@ const Map<String, int> Function(String, int) instantiation1 =
|
|||
/*cfe.Instantiation(method2<String,int>)*/ method2;
|
||||
|
||||
main() {
|
||||
print(/*Function(method1)*/ function0);
|
||||
// TODO(paulberry): analyzer should record instantiation information. See
|
||||
// dartbug.com/37608.
|
||||
print(
|
||||
/*cfe|dart2js.Function(method1)*/
|
||||
/*analyzer.Function(method1,type=T Function<T>(T))*/
|
||||
function0);
|
||||
print(
|
||||
/*cfe|dart2js.Instantiation(method1<int>)*/
|
||||
/*analyzer.Function(method1)*/
|
||||
/*analyzer.Function(method1,type=int Function(int))*/
|
||||
instantiation0);
|
||||
print(
|
||||
/*cfe|dart2js.Instantiation(method2<String,int>)*/
|
||||
/*analyzer.Function(method2)*/
|
||||
/*analyzer.Function(method2,type=Map<String, int> Function(String, int))*/
|
||||
instantiation1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue