fix(52749): Assertion failure in derived class completion (#52787)

This commit is contained in:
Oleksandr T 2023-02-16 00:33:39 +02:00 committed by GitHub
parent 2c67c8f756
commit 733d7aed97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 345 additions and 1 deletions

View File

@ -751,7 +751,7 @@ function createMethodImplementingSignatures(
function getReturnTypeFromSignatures(signatures: readonly Signature[], checker: TypeChecker, context: TypeConstructionContext, enclosingDeclaration: ClassLikeDeclaration): TypeNode | undefined {
if (length(signatures)) {
const type = checker.getUnionType(map(signatures, checker.getReturnTypeOfSignature));
return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
return checker.typeToTypeNode(type, enclosingDeclaration, NodeBuilderFlags.NoTruncation, getNoopSymbolTrackerWithResolver(context));
}
}

View File

@ -0,0 +1,319 @@
=== /foo.ts ===
// export class Observable<T> {
// pipe(): Observable<T>;
// pipe<A>(): Observable<A>;
// pipe<A, B>(): Observable<B>;
// pipe<A, B, C>(): Observable<C>;
// pipe<A, B, C, D>(): Observable<D>;
// pipe<A, B, C, D, E>(): Observable<E>;
// pipe<A, B, C, D, E, F>(): Observable<F>;
// pipe<A, B, C, D, E, F, G>(): Observable<G>;
// pipe<A, B, C, D, E, F, G, H>(): Observable<H>;
// pipe<A, B, C, D, E, F, G, H, I>(): Observable<I>;
// pipe<A, B, C, D, E, F, G, H, I>(): Observable<unknown>;
// }
// export class Foo extends Observable<any> {
//
// ^
// | ----------------------------------------------------------------------
// | abstract
// | accessor
// | async
// | constructor
// | declare
// | get
// | override
// | private
// | protected
// | public
// | readonly
// | set
// | static
// | (method) Observable<any>.pipe(): Observable<any> (+10 overloads)
// | ----------------------------------------------------------------------
// }
[
{
"marker": {
"fileName": "/foo.ts",
"position": 543,
"name": ""
},
"item": {
"flags": 0,
"isGlobalCompletion": false,
"isMemberCompletion": true,
"isNewIdentifierLocation": true,
"entries": [
{
"name": "abstract",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "abstract",
"kind": "keyword"
}
]
},
{
"name": "accessor",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "accessor",
"kind": "keyword"
}
]
},
{
"name": "async",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "async",
"kind": "keyword"
}
]
},
{
"name": "constructor",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "constructor",
"kind": "keyword"
}
]
},
{
"name": "declare",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "declare",
"kind": "keyword"
}
]
},
{
"name": "get",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "get",
"kind": "keyword"
}
]
},
{
"name": "override",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "override",
"kind": "keyword"
}
]
},
{
"name": "private",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "private",
"kind": "keyword"
}
]
},
{
"name": "protected",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "protected",
"kind": "keyword"
}
]
},
{
"name": "public",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "public",
"kind": "keyword"
}
]
},
{
"name": "readonly",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "readonly",
"kind": "keyword"
}
]
},
{
"name": "set",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "set",
"kind": "keyword"
}
]
},
{
"name": "static",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "static",
"kind": "keyword"
}
]
},
{
"name": "pipe",
"kind": "method",
"kindModifiers": "",
"sortText": "17",
"insertText": "pipe(): Observable<any>;\npipe<A>(): Observable<A>;\npipe<A, B>(): Observable<B>;\npipe<A, B, C>(): Observable<C>;\npipe<A, B, C, D>(): Observable<D>;\npipe<A, B, C, D, E>(): Observable<E>;\npipe<A, B, C, D, E, F>(): Observable<F>;\npipe<A, B, C, D, E, F, G>(): Observable<G>;\npipe<A, B, C, D, E, F, G, H>(): Observable<H>;\npipe<A, B, C, D, E, F, G, H, I>(): Observable<I>;\npipe<A, B, C, D, E, F, G, H, I>(): Observable<unknown>;\npipe(): Observable<any> | Observable<A> | Observable<B> | Observable<C> | Observable<D> | Observable<E> | Observable<F> | Observable<G> | Observable<H> | Observable<I> | Observable<unknown> {\n $0\n}",
"isSnippet": true,
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Observable",
"kind": "className"
},
{
"text": "<",
"kind": "punctuation"
},
{
"text": "any",
"kind": "keyword"
},
{
"text": ">",
"kind": "punctuation"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "pipe",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Observable",
"kind": "className"
},
{
"text": "<",
"kind": "punctuation"
},
{
"text": "any",
"kind": "keyword"
},
{
"text": ">",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "+",
"kind": "operator"
},
{
"text": "10",
"kind": "numericLiteral"
},
{
"text": " ",
"kind": "space"
},
{
"text": "overloads",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
}
],
"documentation": []
}
]
}
}
]

View File

@ -0,0 +1,25 @@
/// <reference path="fourslash.ts" />
// @filename: /foo.ts
////export class Observable<T> {
//// pipe(): Observable<T>;
//// pipe<A>(): Observable<A>;
//// pipe<A, B>(): Observable<B>;
//// pipe<A, B, C>(): Observable<C>;
//// pipe<A, B, C, D>(): Observable<D>;
//// pipe<A, B, C, D, E>(): Observable<E>;
//// pipe<A, B, C, D, E, F>(): Observable<F>;
//// pipe<A, B, C, D, E, F, G>(): Observable<G>;
//// pipe<A, B, C, D, E, F, G, H>(): Observable<H>;
//// pipe<A, B, C, D, E, F, G, H, I>(): Observable<I>;
//// pipe<A, B, C, D, E, F, G, H, I>(): Observable<unknown>;
////}
////export class Foo extends Observable<any> {
//// /**/
////}
verify.baselineCompletions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithClassMemberSnippets: true,
});