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

Unified Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 2356843002: Fix 'new KnownClass.unresolvedConstructor()' type computation. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/link.dart
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index f085b6146f38d4228523b95f606b80f07bafc6a2..6ed601185e1a7c4d0260281fb60d9171fdbf4651 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -363,6 +363,9 @@ abstract class ClassElementForLink extends Object
List<PropertyAccessorElementForLink> get accessors;
@override
+ ClassElementForLink get asClass => this;
+
+ @override
ConstructorElementForLink get asConstructor => unnamedConstructor;
@override
@@ -985,6 +988,23 @@ abstract class CompilationUnitElementForLink
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
/**
+ * Return the class element for the constructor referred to by the given
+ * [index] in [UnlinkedUnit.references]. If the reference is unresolved,
+ * return [UndefinedElementForLink.instance].
+ */
+ ReferenceableElementForLink resolveConstructorClassRef(int index) {
+ LinkedReference linkedReference = _linkedUnit.references[index];
+ if (linkedReference.kind == ReferenceKind.classOrEnum) {
+ return resolveRef(index);
+ }
+ if (index < _unlinkedUnit.references.length) {
+ UnlinkedReference unlinkedReference = _unlinkedUnit.references[index];
+ return resolveRef(unlinkedReference.prefixReference);
+ }
+ return UndefinedElementForLink.instance;
+ }
+
+ /**
* Return the element referred to by the given [index] in
* [UnlinkedUnit.references]. If the reference is unresolved,
* return [UndefinedElementForLink.instance].
@@ -2379,11 +2399,10 @@ class ExprTypeComputer {
stack.length -= numNamed + numPositional;
strPtr += numNamed;
EntityRef ref = _getNextRef();
- ConstructorElementForLink element =
- unit.resolveRef(ref.reference).asConstructor;
+ ClassElementForLink_Class element =
+ unit.resolveConstructorClassRef(ref.reference).asClass;
if (element != null) {
- ClassElementForLink_Class enclosingClass = element.enclosingClass;
- stack.add(enclosingClass.buildType((int i) {
+ stack.add(element.buildType((int i) {
// Type argument explicitly specified.
if (i < ref.typeArguments.length) {
return unit.resolveTypeRef(
@@ -4359,6 +4378,11 @@ class PropertyAccessorElementForLink_Variable extends Object
*/
abstract class ReferenceableElementForLink implements Element {
/**
+ * If this element is a class reference, return it. Otherwise return `null`.
+ */
+ ClassElementForLink get asClass => null;
+
+ /**
* If this element can be used in a constructor invocation context,
* return the associated constructor (which may be `this` or some
* other element). Otherwise return `null`.
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698