Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1960933002: Fix AST summarization of synthetic function types and method tear-offs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 } 2142 }
2143 } 2143 }
2144 } 2144 }
2145 parameterElement.synthetic = synthetic; 2145 parameterElement.synthetic = synthetic;
2146 buildAnnotations(parameterElement, serializedParameter.annotations); 2146 buildAnnotations(parameterElement, serializedParameter.annotations);
2147 buildCodeRange(parameterElement, serializedParameter.codeRange); 2147 buildCodeRange(parameterElement, serializedParameter.codeRange);
2148 if (serializedParameter.isFunctionTyped) { 2148 if (serializedParameter.isFunctionTyped) {
2149 FunctionElementImpl parameterTypeElement = 2149 FunctionElementImpl parameterTypeElement =
2150 new FunctionElementImpl('', -1); 2150 new FunctionElementImpl('', -1);
2151 parameterTypeElement.synthetic = true; 2151 parameterTypeElement.synthetic = true;
2152 parameterElement.parameters = 2152 List<ParameterElement> subParameters = serializedParameter.parameters
2153 serializedParameter.parameters.map(buildParameter).toList(); 2153 .map((UnlinkedParam p) => buildParameter(p, synthetic: synthetic))
2154 parameterTypeElement.enclosingElement = parameterElement; 2154 .toList();
2155 parameterTypeElement.shareParameters(parameterElement.parameters); 2155 if (synthetic) {
2156 parameterTypeElement.parameters = subParameters;
2157 } else {
2158 parameterElement.parameters = subParameters;
2159 parameterTypeElement.shareParameters(subParameters);
2160 parameterTypeElement.enclosingElement = parameterElement;
2161 }
2156 parameterTypeElement.returnType = buildType(serializedParameter.type); 2162 parameterTypeElement.returnType = buildType(serializedParameter.type);
2157 parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs( 2163 parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
2158 parameterTypeElement, null, getCurrentTypeArguments(), false); 2164 parameterTypeElement, null, getCurrentTypeArguments(), false);
2165 parameterTypeElement.type = parameterElement.type;
2159 } else { 2166 } else {
2160 if (serializedParameter.isInitializingFormal && 2167 if (serializedParameter.isInitializingFormal &&
2161 serializedParameter.type == null) { 2168 serializedParameter.type == null) {
2162 // The type is inherited from the matching field. 2169 // The type is inherited from the matching field.
2163 parameterElement.type = 2170 parameterElement.type =
2164 fields[serializedParameter.name]?.type ?? DynamicTypeImpl.instance; 2171 fields[serializedParameter.name]?.type ?? DynamicTypeImpl.instance;
2165 } else { 2172 } else {
2166 parameterElement.type = 2173 parameterElement.type =
2167 buildLinkedType(serializedParameter.inferredTypeSlot) ?? 2174 buildLinkedType(serializedParameter.inferredTypeSlot) ??
2168 buildType(serializedParameter.type); 2175 buildType(serializedParameter.type);
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2656 static String _getElementIdentifier(String name, ReferenceKind kind) { 2663 static String _getElementIdentifier(String name, ReferenceKind kind) {
2657 if (kind == ReferenceKind.topLevelPropertyAccessor || 2664 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2658 kind == ReferenceKind.propertyAccessor) { 2665 kind == ReferenceKind.propertyAccessor) {
2659 if (!name.endsWith('=')) { 2666 if (!name.endsWith('=')) {
2660 return name + '?'; 2667 return name + '?';
2661 } 2668 }
2662 } 2669 }
2663 return name; 2670 return name;
2664 } 2671 }
2665 } 2672 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698