Skip to content

Commit ba8b168

Browse files
committed
Included previously ignored baseline .js file and slight refactoring
1 parent 2d7a0f4 commit ba8b168

File tree

2 files changed

+96
-4
lines changed

2 files changed

+96
-4
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15412,14 +15412,13 @@ namespace ts {
1541215412

1541315413
function isNodeWithinClass(node: Node, classDeclaration: ClassLikeDeclaration) {
1541415414
while (true) {
15415-
const containingClass = getContainingClass(node);
15416-
if (!containingClass) {
15415+
node = getContainingClass(node);
15416+
if (!node) {
1541715417
return false;
1541815418
}
15419-
if (containingClass === classDeclaration) {
15419+
if (node === classDeclaration) {
1542015420
return true;
1542115421
}
15422-
node = containingClass;
1542315422
}
1542415423
}
1542515424

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//// [classConstructorAccessibility4.ts]
2+
3+
class A {
4+
private constructor() { }
5+
6+
method() {
7+
class B {
8+
method() {
9+
new A(); // OK
10+
}
11+
}
12+
13+
class C extends A { // OK
14+
}
15+
}
16+
}
17+
18+
class D {
19+
protected constructor() { }
20+
21+
method() {
22+
class E {
23+
method() {
24+
new D(); // OK
25+
}
26+
}
27+
28+
class F extends D { // OK
29+
}
30+
}
31+
}
32+
33+
//// [classConstructorAccessibility4.js]
34+
var __extends = (this && this.__extends) || function (d, b) {
35+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
36+
function __() { this.constructor = d; }
37+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
38+
};
39+
var A = (function () {
40+
function A() {
41+
}
42+
A.prototype.method = function () {
43+
var B = (function () {
44+
function B() {
45+
}
46+
B.prototype.method = function () {
47+
new A(); // OK
48+
};
49+
return B;
50+
}());
51+
var C = (function (_super) {
52+
__extends(C, _super);
53+
function C() {
54+
_super.apply(this, arguments);
55+
}
56+
return C;
57+
}(A));
58+
};
59+
return A;
60+
}());
61+
var D = (function () {
62+
function D() {
63+
}
64+
D.prototype.method = function () {
65+
var E = (function () {
66+
function E() {
67+
}
68+
E.prototype.method = function () {
69+
new D(); // OK
70+
};
71+
return E;
72+
}());
73+
var F = (function (_super) {
74+
__extends(F, _super);
75+
function F() {
76+
_super.apply(this, arguments);
77+
}
78+
return F;
79+
}(D));
80+
};
81+
return D;
82+
}());
83+
84+
85+
//// [classConstructorAccessibility4.d.ts]
86+
declare class A {
87+
private constructor();
88+
method(): void;
89+
}
90+
declare class D {
91+
protected constructor();
92+
method(): void;
93+
}

0 commit comments

Comments
 (0)