Skip to content

[Master] Fix resolve entity name to not dive inside property access expression when the expression is not entity name - #14692

Merged
Yui (yuit) merged 3 commits into
masterfrom
master-fixResolveEntityName
Mar 29, 2017
Merged

[Master] Fix resolve entity name to not dive inside property access expression when the expression is not entity name#14692
Yui (yuit) merged 3 commits into
masterfrom
master-fixResolveEntityName

Conversation

@yuit

@yuitYui (yuit) commented Mar 16, 2017

Copy link
Copy Markdown
Contributor

While writing tests for dynamic import, I ran into Debug.fail("Unknown entity name kind."); inside resolveEntityName function, turned out that it not only causes failure when writing out ".types" files but also disable some language services features (see test files)

@yuitYui (yuit) mentioned this pull request Mar 21, 2017
5 tasks
@yuit
Yui (yuit) merged commit 0cb490e into masterMar 29, 2017
@yuit
Yui (yuit) deleted the master-fixResolveEntityName branch March 29, 2017 16:55

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, although the new fallback behaviour in getSymbolOfEntityNameOrPropertyAccess is somewhat confusing.

//// }
//// var x: {
//// B : CTor
//// };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 1-9 don't seem necessary for this test

//// }
//// var x: {
//// B : CTor
//// };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 1-9 don't seem necessary for this test

//// }
//// var x: {
//// B : CTor
//// };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 1-9 don't seem necessary for this test

//// class C extends (foo()).[|B|] {}
//// class C1 extends foo().[|B|] {}

const [def, ref1, ref2] = test.ranges();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this instead:

constrs=test.ranges();for(constrofrs){verify.referencesOf(r,rs));}

}
}
else if (name.kind === SyntaxKind.ParenthesizedExpression) {
// If the expression in parenthsizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:parenthesized

// i.e class C extends foo()./*do language service operation here*/B {}
return isEntityNameExpression(name.expression) ?
resolveEntityName(name.expression as EntityNameOrEntityNameExpression, meaning, ignoreErrors, dontResolveAlias, location) :
undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also give an error in the undefined case?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't because the caller will already handle this case.

}
var x: {
B : CTor
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out lines 1-7 aren't used here either!

@microsoftMicrosoft (microsoft) locked and limited conversation to collaborators Jun 21, 2018
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@yuit@sandersn@msftclas