Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Included previously ignored baseline .js file and slight refactoring
  • Loading branch information
AbubakerB committed Feb 14, 2016
commit ba8b1680cbf5fa5763fe1d6000a36ac05d8bdb43
7 changes: 3 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15412,14 +15412,13 @@ namespace ts {

function isNodeWithinClass(node: Node, classDeclaration: ClassLikeDeclaration) {
while (true) {
const containingClass = getContainingClass(node);
if (!containingClass) {
node = getContainingClass(node);
if (!node) {
return false;
}
if (containingClass === classDeclaration) {
if (node === classDeclaration) {
return true;
}
node = containingClass;
}
}

Expand Down
93 changes: 93 additions & 0 deletions tests/baselines/reference/classConstructorAccessibility4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//// [classConstructorAccessibility4.ts]

class A {
private constructor() { }

method() {
class B {
method() {
new A(); // OK
}
}

class C extends A { // OK
}
}
}

class D {
protected constructor() { }

method() {
class E {
method() {
new D(); // OK
}
}

class F extends D { // OK
}
}
}

//// [classConstructorAccessibility4.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var A = (function () {
function A() {
}
A.prototype.method = function () {
var B = (function () {
function B() {
}
B.prototype.method = function () {
new A(); // OK
};
return B;
}());
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
return C;
}(A));
};
return A;
}());
var D = (function () {
function D() {
}
D.prototype.method = function () {
var E = (function () {
function E() {
}
E.prototype.method = function () {
new D(); // OK
};
return E;
}());
var F = (function (_super) {
__extends(F, _super);
function F() {
_super.apply(this, arguments);
}
return F;
}(D));
};
return D;
}());


//// [classConstructorAccessibility4.d.ts]
declare class A {
private constructor();
method(): void;
}
declare class D {
protected constructor();
method(): void;
}