Skip to content

Commit a8732d7

Browse files
committed
Merge branch 'master' into fixUnionReduction
Conflicts: tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction2.errors.txt tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction2.js tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction2.ts
2 parents fdc44b2 + 7dd1f3f commit a8732d7

29 files changed

+546
-69
lines changed

bin/tsc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24992,7 +24992,7 @@ var ts;
2499224992
ts.emitTime = 0;
2499324993
ts.ioReadTime = 0;
2499424994
ts.ioWriteTime = 0;
24995-
ts.version = "1.5.0";
24995+
ts.version = "1.5.2";
2499624996
var carriageReturnLineFeed = "\r\n";
2499724997
var lineFeed = "\n";
2499824998
function findConfigFile(searchPath) {

bin/tsserver.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25376,7 +25376,7 @@ var ts;
2537625376
ts.emitTime = 0;
2537725377
ts.ioReadTime = 0;
2537825378
ts.ioWriteTime = 0;
25379-
ts.version = "1.5.0";
25379+
ts.version = "1.5.2";
2538025380
var carriageReturnLineFeed = "\r\n";
2538125381
var lineFeed = "\n";
2538225382
function findConfigFile(searchPath) {
@@ -31202,8 +31202,9 @@ var ts;
3120231202
})();
3120331203
ts.CancellationTokenObject = CancellationTokenObject;
3120431204
var HostCache = (function () {
31205-
function HostCache(host) {
31205+
function HostCache(host, getCanonicalFileName) {
3120631206
this.host = host;
31207+
this.getCanonicalFileName = getCanonicalFileName;
3120731208
this.fileNameToEntry = {};
3120831209
var rootFileNames = host.getScriptFileNames();
3120931210
for (var _i = 0; _i < rootFileNames.length; _i++) {
@@ -31215,6 +31216,9 @@ var ts;
3121531216
HostCache.prototype.compilationSettings = function () {
3121631217
return this._compilationSettings;
3121731218
};
31219+
HostCache.prototype.normalizeFileName = function (fileName) {
31220+
return this.getCanonicalFileName(ts.normalizeSlashes(fileName));
31221+
};
3121831222
HostCache.prototype.createEntry = function (fileName) {
3121931223
var entry;
3122031224
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
@@ -31225,13 +31229,13 @@ var ts;
3122531229
scriptSnapshot: scriptSnapshot
3122631230
};
3122731231
}
31228-
return this.fileNameToEntry[ts.normalizeSlashes(fileName)] = entry;
31232+
return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry;
3122931233
};
3123031234
HostCache.prototype.getEntry = function (fileName) {
31231-
return ts.lookUp(this.fileNameToEntry, ts.normalizeSlashes(fileName));
31235+
return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName));
3123231236
};
3123331237
HostCache.prototype.contains = function (fileName) {
31234-
return ts.hasProperty(this.fileNameToEntry, ts.normalizeSlashes(fileName));
31238+
return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName));
3123531239
};
3123631240
HostCache.prototype.getOrCreateEntry = function (fileName) {
3123731241
if (this.contains(fileName)) {
@@ -31243,8 +31247,10 @@ var ts;
3124331247
var _this = this;
3124431248
var fileNames = [];
3124531249
ts.forEachKey(this.fileNameToEntry, function (key) {
31246-
if (ts.hasProperty(_this.fileNameToEntry, key) && _this.fileNameToEntry[key])
31247-
fileNames.push(key);
31250+
var entry = _this.getEntry(key);
31251+
if (entry) {
31252+
fileNames.push(entry.hostFileName);
31253+
}
3124831254
});
3124931255
return fileNames;
3125031256
};
@@ -31774,7 +31780,7 @@ var ts;
3177431780
return ruleProvider;
3177531781
}
3177631782
function synchronizeHostData() {
31777-
var hostCache = new HostCache(host);
31783+
var hostCache = new HostCache(host, getCanonicalFileName);
3177831784
if (programUpToDate()) {
3177931785
return;
3178031786
}
@@ -31784,7 +31790,7 @@ var ts;
3178431790
var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, {
3178531791
getSourceFile: getOrCreateSourceFile,
3178631792
getCancellationToken: function () { return cancellationToken; },
31787-
getCanonicalFileName: function (fileName) { return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); },
31793+
getCanonicalFileName: getCanonicalFileName,
3178831794
useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; },
3178931795
getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; },
3179031796
getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },

bin/typescript.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29571,7 +29571,7 @@ var ts;
2957129571
/* @internal */ ts.ioReadTime = 0;
2957229572
/* @internal */ ts.ioWriteTime = 0;
2957329573
/** The version of the TypeScript compiler release */
29574-
ts.version = "1.5.0";
29574+
ts.version = "1.5.2";
2957529575
var carriageReturnLineFeed = "\r\n";
2957629576
var lineFeed = "\n";
2957729577
function findConfigFile(searchPath) {
@@ -36487,8 +36487,9 @@ var ts;
3648736487
// at each language service public entry point, since we don't know when
3648836488
// set of scripts handled by the host changes.
3648936489
var HostCache = (function () {
36490-
function HostCache(host) {
36490+
function HostCache(host, getCanonicalFileName) {
3649136491
this.host = host;
36492+
this.getCanonicalFileName = getCanonicalFileName;
3649236493
// script id => script index
3649336494
this.fileNameToEntry = {};
3649436495
// Initialize the list with the root file names
@@ -36503,6 +36504,9 @@ var ts;
3650336504
HostCache.prototype.compilationSettings = function () {
3650436505
return this._compilationSettings;
3650536506
};
36507+
HostCache.prototype.normalizeFileName = function (fileName) {
36508+
return this.getCanonicalFileName(ts.normalizeSlashes(fileName));
36509+
};
3650636510
HostCache.prototype.createEntry = function (fileName) {
3650736511
var entry;
3650836512
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
@@ -36513,13 +36517,13 @@ var ts;
3651336517
scriptSnapshot: scriptSnapshot
3651436518
};
3651536519
}
36516-
return this.fileNameToEntry[ts.normalizeSlashes(fileName)] = entry;
36520+
return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry;
3651736521
};
3651836522
HostCache.prototype.getEntry = function (fileName) {
36519-
return ts.lookUp(this.fileNameToEntry, ts.normalizeSlashes(fileName));
36523+
return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName));
3652036524
};
3652136525
HostCache.prototype.contains = function (fileName) {
36522-
return ts.hasProperty(this.fileNameToEntry, ts.normalizeSlashes(fileName));
36526+
return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName));
3652336527
};
3652436528
HostCache.prototype.getOrCreateEntry = function (fileName) {
3652536529
if (this.contains(fileName)) {
@@ -36531,8 +36535,10 @@ var ts;
3653136535
var _this = this;
3653236536
var fileNames = [];
3653336537
ts.forEachKey(this.fileNameToEntry, function (key) {
36534-
if (ts.hasProperty(_this.fileNameToEntry, key) && _this.fileNameToEntry[key])
36535-
fileNames.push(key);
36538+
var entry = _this.getEntry(key);
36539+
if (entry) {
36540+
fileNames.push(entry.hostFileName);
36541+
}
3653636542
});
3653736543
return fileNames;
3653836544
};
@@ -37151,7 +37157,7 @@ var ts;
3715137157
}
3715237158
function synchronizeHostData() {
3715337159
// Get a fresh cache of the host information
37154-
var hostCache = new HostCache(host);
37160+
var hostCache = new HostCache(host, getCanonicalFileName);
3715537161
// If the program is already up-to-date, we can reuse it
3715637162
if (programUpToDate()) {
3715737163
return;
@@ -37168,7 +37174,7 @@ var ts;
3716837174
var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, {
3716937175
getSourceFile: getOrCreateSourceFile,
3717037176
getCancellationToken: function () { return cancellationToken; },
37171-
getCanonicalFileName: function (fileName) { return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); },
37177+
getCanonicalFileName: getCanonicalFileName,
3717237178
useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; },
3717337179
getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; },
3717437180
getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },

bin/typescriptServices.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29571,7 +29571,7 @@ var ts;
2957129571
/* @internal */ ts.ioReadTime = 0;
2957229572
/* @internal */ ts.ioWriteTime = 0;
2957329573
/** The version of the TypeScript compiler release */
29574-
ts.version = "1.5.0";
29574+
ts.version = "1.5.2";
2957529575
var carriageReturnLineFeed = "\r\n";
2957629576
var lineFeed = "\n";
2957729577
function findConfigFile(searchPath) {
@@ -36487,8 +36487,9 @@ var ts;
3648736487
// at each language service public entry point, since we don't know when
3648836488
// set of scripts handled by the host changes.
3648936489
var HostCache = (function () {
36490-
function HostCache(host) {
36490+
function HostCache(host, getCanonicalFileName) {
3649136491
this.host = host;
36492+
this.getCanonicalFileName = getCanonicalFileName;
3649236493
// script id => script index
3649336494
this.fileNameToEntry = {};
3649436495
// Initialize the list with the root file names
@@ -36503,6 +36504,9 @@ var ts;
3650336504
HostCache.prototype.compilationSettings = function () {
3650436505
return this._compilationSettings;
3650536506
};
36507+
HostCache.prototype.normalizeFileName = function (fileName) {
36508+
return this.getCanonicalFileName(ts.normalizeSlashes(fileName));
36509+
};
3650636510
HostCache.prototype.createEntry = function (fileName) {
3650736511
var entry;
3650836512
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
@@ -36513,13 +36517,13 @@ var ts;
3651336517
scriptSnapshot: scriptSnapshot
3651436518
};
3651536519
}
36516-
return this.fileNameToEntry[ts.normalizeSlashes(fileName)] = entry;
36520+
return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry;
3651736521
};
3651836522
HostCache.prototype.getEntry = function (fileName) {
36519-
return ts.lookUp(this.fileNameToEntry, ts.normalizeSlashes(fileName));
36523+
return ts.lookUp(this.fileNameToEntry, this.normalizeFileName(fileName));
3652036524
};
3652136525
HostCache.prototype.contains = function (fileName) {
36522-
return ts.hasProperty(this.fileNameToEntry, ts.normalizeSlashes(fileName));
36526+
return ts.hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName));
3652336527
};
3652436528
HostCache.prototype.getOrCreateEntry = function (fileName) {
3652536529
if (this.contains(fileName)) {
@@ -36531,8 +36535,10 @@ var ts;
3653136535
var _this = this;
3653236536
var fileNames = [];
3653336537
ts.forEachKey(this.fileNameToEntry, function (key) {
36534-
if (ts.hasProperty(_this.fileNameToEntry, key) && _this.fileNameToEntry[key])
36535-
fileNames.push(key);
36538+
var entry = _this.getEntry(key);
36539+
if (entry) {
36540+
fileNames.push(entry.hostFileName);
36541+
}
3653636542
});
3653736543
return fileNames;
3653836544
};
@@ -37151,7 +37157,7 @@ var ts;
3715137157
}
3715237158
function synchronizeHostData() {
3715337159
// Get a fresh cache of the host information
37154-
var hostCache = new HostCache(host);
37160+
var hostCache = new HostCache(host, getCanonicalFileName);
3715537161
// If the program is already up-to-date, we can reuse it
3715637162
if (programUpToDate()) {
3715737163
return;
@@ -37168,7 +37174,7 @@ var ts;
3716837174
var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, {
3716937175
getSourceFile: getOrCreateSourceFile,
3717037176
getCancellationToken: function () { return cancellationToken; },
37171-
getCanonicalFileName: function (fileName) { return useCaseSensitivefileNames ? fileName : fileName.toLowerCase(); },
37177+
getCanonicalFileName: getCanonicalFileName,
3717237178
useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; },
3717337179
getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; },
3717437180
getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "http://typescriptlang.org/",
5-
"version": "1.5.0",
5+
"version": "1.5.2",
66
"licenses": [
77
{
88
"type": "Apache License 2.0",

src/compiler/checker.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3567,14 +3567,28 @@ module ts {
35673567
return false;
35683568
}
35693569

3570+
// Since removeSubtypes checks the subtype relation, and the subtype relation on a union
3571+
// may attempt to reduce a union, it is possible that removeSubtypes could be called
3572+
// recursively on the same set of types. The removeSubtypesStack is used to track which
3573+
// sets of types are currently undergoing subtype reduction.
3574+
let removeSubtypesStack: string[] = [];
35703575
function removeSubtypes(types: Type[]) {
3576+
let typeListId = getTypeListId(types);
3577+
if (removeSubtypesStack.lastIndexOf(typeListId) >= 0) {
3578+
return;
3579+
}
3580+
3581+
removeSubtypesStack.push(typeListId);
3582+
35713583
let i = types.length;
35723584
while (i > 0) {
35733585
i--;
35743586
if (isSubtypeOfAny(types[i], types)) {
35753587
types.splice(i, 1);
35763588
}
35773589
}
3590+
3591+
removeSubtypesStack.pop();
35783592
}
35793593

35803594
function containsAnyType(types: Type[]) {

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module ts {
88
/* @internal */ export let ioWriteTime = 0;
99

1010
/** The version of the TypeScript compiler release */
11-
export const version = "1.5.0";
11+
export const version = "1.5.2";
1212

1313
const carriageReturnLineFeed = "\r\n";
1414
const lineFeed = "\n";

0 commit comments

Comments
 (0)