From 0fa89ad99c41ab747511baf2ba6eefb0d48e5a9c Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 12 Oct 2015 17:38:55 -0700 Subject: [PATCH] Fixes #5104. --- src/compiler/core.ts | 8 +++-- .../reference/decoratorCallGeneric.errors.txt | 22 +++++++++++++ .../reference/decoratorCallGeneric.js | 31 +++++++++++++++++++ .../decorators/decoratorCallGeneric.ts | 12 +++++++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/decoratorCallGeneric.errors.txt create mode 100644 tests/baselines/reference/decoratorCallGeneric.js create mode 100644 tests/cases/conformance/decorators/decoratorCallGeneric.ts diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ce59c3b3bc6..a310ceec457 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -437,8 +437,12 @@ namespace ts { } export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain { - Debug.assert(!headChain.next); - headChain.next = tailChain; + let lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next; + } + + lastChain.next = tailChain; return headChain; } diff --git a/tests/baselines/reference/decoratorCallGeneric.errors.txt b/tests/baselines/reference/decoratorCallGeneric.errors.txt new file mode 100644 index 00000000000..c8443420740 --- /dev/null +++ b/tests/baselines/reference/decoratorCallGeneric.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS1238: Unable to resolve signature of class decorator when called as an expression. + The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate 'C' is not a valid type argument because it is not a supertype of candidate 'void'. + + +==== tests/cases/conformance/decorators/decoratorCallGeneric.ts (1 errors) ==== + interface I { + prototype: T, + m: () => T + } + function dec(c: I) { } + + @dec + ~~~ +!!! error TS1238: Unable to resolve signature of class decorator when called as an expression. +!!! error TS1238: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS1238: Type argument candidate 'C' is not a valid type argument because it is not a supertype of candidate 'void'. + class C { + _brand: any; + static m() {} + } + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorCallGeneric.js b/tests/baselines/reference/decoratorCallGeneric.js new file mode 100644 index 00000000000..8c141d5a131 --- /dev/null +++ b/tests/baselines/reference/decoratorCallGeneric.js @@ -0,0 +1,31 @@ +//// [decoratorCallGeneric.ts] +interface I { + prototype: T, + m: () => T +} +function dec(c: I) { } + +@dec +class C { + _brand: any; + static m() {} +} + + +//// [decoratorCallGeneric.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +function dec(c) { } +var C = (function () { + function C() { + } + C.m = function () { }; + C = __decorate([ + dec + ], C); + return C; +})(); diff --git a/tests/cases/conformance/decorators/decoratorCallGeneric.ts b/tests/cases/conformance/decorators/decoratorCallGeneric.ts new file mode 100644 index 00000000000..3eeaae6837c --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorCallGeneric.ts @@ -0,0 +1,12 @@ +// @experimentalDecorators: true +interface I { + prototype: T, + m: () => T +} +function dec(c: I) { } + +@dec +class C { + _brand: any; + static m() {} +}