Skip to content

Commit ed2e105

Browse files
committed
Merge branch 'master' into rootDir
2 parents 08a8692 + 02a480d commit ed2e105

7 files changed

+244
-3
lines changed

src/compiler/checker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3788,7 +3788,7 @@ module ts {
37883788
}
37893789

37903790
function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper {
3791-
return t => mapper2(mapper1(t));
3791+
return t => instantiateType(mapper1(t), mapper2);
37923792
}
37933793

37943794
function instantiateTypeParameter(typeParameter: TypeParameter, mapper: TypeMapper): TypeParameter {
@@ -3859,7 +3859,7 @@ module ts {
38593859
function instantiateType(type: Type, mapper: TypeMapper): Type {
38603860
if (mapper !== identityMapper) {
38613861
if (type.flags & TypeFlags.TypeParameter) {
3862-
return mapper(type);
3862+
return mapper(<TypeParameter>type);
38633863
}
38643864
if (type.flags & TypeFlags.Anonymous) {
38653865
return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) ?

src/compiler/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ module ts {
15771577

15781578
/* @internal */
15791579
export interface TypeMapper {
1580-
(t: Type): Type;
1580+
(t: TypeParameter): Type;
15811581
}
15821582

15831583
/* @internal */

src/server/session.ts

+3
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ module ts.server {
527527
if (lineText.charAt(i) == " ") {
528528
indentPosition--;
529529
}
530+
else if (lineText.charAt(i) == "\t") {
531+
indentPosition -= editorOptions.IndentSize;
532+
}
530533
else {
531534
break;
532535
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//// [baseTypeWrappingInstantiationChain.ts]
2+
class C<T1> extends CBase<T1> {
3+
public works() {
4+
new CBaseBase<Wrapper<T1>>(this);
5+
}
6+
public alsoWorks() {
7+
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
8+
}
9+
10+
public method(t: Wrapper<T1>) { }
11+
}
12+
13+
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
14+
15+
}
16+
17+
class CBaseBase<T3> {
18+
constructor(x: Parameter<T3>) { }
19+
}
20+
21+
class Parameter<T4> {
22+
method(t: T4) { }
23+
}
24+
25+
class Wrapper<T5> {
26+
property: T5;
27+
}
28+
29+
//// [baseTypeWrappingInstantiationChain.js]
30+
var __extends = this.__extends || function (d, b) {
31+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
32+
function __() { this.constructor = d; }
33+
__.prototype = b.prototype;
34+
d.prototype = new __();
35+
};
36+
var C = (function (_super) {
37+
__extends(C, _super);
38+
function C() {
39+
_super.apply(this, arguments);
40+
}
41+
C.prototype.works = function () {
42+
new CBaseBase(this);
43+
};
44+
C.prototype.alsoWorks = function () {
45+
new CBase(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
46+
};
47+
C.prototype.method = function (t) { };
48+
return C;
49+
})(CBase);
50+
var CBase = (function (_super) {
51+
__extends(CBase, _super);
52+
function CBase() {
53+
_super.apply(this, arguments);
54+
}
55+
return CBase;
56+
})(CBaseBase);
57+
var CBaseBase = (function () {
58+
function CBaseBase(x) {
59+
}
60+
return CBaseBase;
61+
})();
62+
var Parameter = (function () {
63+
function Parameter() {
64+
}
65+
Parameter.prototype.method = function (t) { };
66+
return Parameter;
67+
})();
68+
var Wrapper = (function () {
69+
function Wrapper() {
70+
}
71+
return Wrapper;
72+
})();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
=== tests/cases/compiler/baseTypeWrappingInstantiationChain.ts ===
2+
class C<T1> extends CBase<T1> {
3+
>C : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
4+
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
5+
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1))
6+
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
7+
8+
public works() {
9+
>works : Symbol(works, Decl(baseTypeWrappingInstantiationChain.ts, 0, 31))
10+
11+
new CBaseBase<Wrapper<T1>>(this);
12+
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1))
13+
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
14+
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
15+
>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
16+
}
17+
public alsoWorks() {
18+
>alsoWorks : Symbol(alsoWorks, Decl(baseTypeWrappingInstantiationChain.ts, 3, 5))
19+
20+
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
21+
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1))
22+
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
23+
>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0))
24+
}
25+
26+
public method(t: Wrapper<T1>) { }
27+
>method : Symbol(method, Decl(baseTypeWrappingInstantiationChain.ts, 6, 5))
28+
>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 8, 18))
29+
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
30+
>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8))
31+
}
32+
33+
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
34+
>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1))
35+
>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 11, 12))
36+
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1))
37+
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
38+
>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 11, 12))
39+
40+
}
41+
42+
class CBaseBase<T3> {
43+
>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1))
44+
>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 15, 16))
45+
46+
constructor(x: Parameter<T3>) { }
47+
>x : Symbol(x, Decl(baseTypeWrappingInstantiationChain.ts, 16, 16))
48+
>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 17, 1))
49+
>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 15, 16))
50+
}
51+
52+
class Parameter<T4> {
53+
>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 17, 1))
54+
>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 19, 16))
55+
56+
method(t: T4) { }
57+
>method : Symbol(method, Decl(baseTypeWrappingInstantiationChain.ts, 19, 21))
58+
>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 20, 11))
59+
>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 19, 16))
60+
}
61+
62+
class Wrapper<T5> {
63+
>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1))
64+
>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 23, 14))
65+
66+
property: T5;
67+
>property : Symbol(property, Decl(baseTypeWrappingInstantiationChain.ts, 23, 19))
68+
>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 23, 14))
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
=== tests/cases/compiler/baseTypeWrappingInstantiationChain.ts ===
2+
class C<T1> extends CBase<T1> {
3+
>C : C<T1>
4+
>T1 : T1
5+
>CBase : CBase<T2>
6+
>T1 : T1
7+
8+
public works() {
9+
>works : () => void
10+
11+
new CBaseBase<Wrapper<T1>>(this);
12+
>new CBaseBase<Wrapper<T1>>(this) : CBaseBase<Wrapper<T1>>
13+
>CBaseBase : typeof CBaseBase
14+
>Wrapper : Wrapper<T5>
15+
>T1 : T1
16+
>this : C<T1>
17+
}
18+
public alsoWorks() {
19+
>alsoWorks : () => void
20+
21+
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
22+
>new CBase<T1>(this) : CBase<T1>
23+
>CBase : typeof CBase
24+
>T1 : T1
25+
>this : C<T1>
26+
}
27+
28+
public method(t: Wrapper<T1>) { }
29+
>method : (t: Wrapper<T1>) => void
30+
>t : Wrapper<T1>
31+
>Wrapper : Wrapper<T5>
32+
>T1 : T1
33+
}
34+
35+
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
36+
>CBase : CBase<T2>
37+
>T2 : T2
38+
>CBaseBase : CBaseBase<T3>
39+
>Wrapper : Wrapper<T5>
40+
>T2 : T2
41+
42+
}
43+
44+
class CBaseBase<T3> {
45+
>CBaseBase : CBaseBase<T3>
46+
>T3 : T3
47+
48+
constructor(x: Parameter<T3>) { }
49+
>x : Parameter<T3>
50+
>Parameter : Parameter<T4>
51+
>T3 : T3
52+
}
53+
54+
class Parameter<T4> {
55+
>Parameter : Parameter<T4>
56+
>T4 : T4
57+
58+
method(t: T4) { }
59+
>method : (t: T4) => void
60+
>t : T4
61+
>T4 : T4
62+
}
63+
64+
class Wrapper<T5> {
65+
>Wrapper : Wrapper<T5>
66+
>T5 : T5
67+
68+
property: T5;
69+
>property : T5
70+
>T5 : T5
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class C<T1> extends CBase<T1> {
2+
public works() {
3+
new CBaseBase<Wrapper<T1>>(this);
4+
}
5+
public alsoWorks() {
6+
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
7+
}
8+
9+
public method(t: Wrapper<T1>) { }
10+
}
11+
12+
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
13+
14+
}
15+
16+
class CBaseBase<T3> {
17+
constructor(x: Parameter<T3>) { }
18+
}
19+
20+
class Parameter<T4> {
21+
method(t: T4) { }
22+
}
23+
24+
class Wrapper<T5> {
25+
property: T5;
26+
}

0 commit comments

Comments
 (0)