fixed loops, merged baseline
This commit is contained in:
parent
fa06f3e4e6
commit
fa9b6fcb07
|
@ -10403,12 +10403,8 @@ module ts {
|
|||
}
|
||||
|
||||
// Non-ambient classes cannot merge with interfaces.
|
||||
if (!(node.flags & NodeFlags.Ambient)) {
|
||||
if (forEach(symbol.declarations, (element: Declaration) => {
|
||||
return element.kind === SyntaxKind.InterfaceDeclaration;
|
||||
})) {
|
||||
error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface)
|
||||
}
|
||||
if (!(node.flags & NodeFlags.Ambient) && getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)) {
|
||||
error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface)
|
||||
}
|
||||
|
||||
forEach(node.members, checkSourceElement);
|
||||
|
@ -10562,15 +10558,6 @@ module ts {
|
|||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the symbol contains a class declaration that is non-ambient.
|
||||
*/
|
||||
function hasNonAmbientClass(symbol: Symbol): boolean {
|
||||
return symbol && forEach(symbol.declarations, (element: Declaration) => {
|
||||
return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient);
|
||||
});
|
||||
}
|
||||
|
||||
function checkInterfaceDeclaration(node: InterfaceDeclaration) {
|
||||
// Grammar checking
|
||||
checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
|
||||
|
@ -10600,10 +10587,12 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
// Interfaces cannot merge with non-ambient classes.
|
||||
if (!(node.flags & NodeFlags.Ambient)) {
|
||||
if (hasNonAmbientClass(symbol)) {
|
||||
error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class);
|
||||
if (symbol && symbol.declarations) {
|
||||
for (let declaration of symbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.ClassDeclaration && !(declaration.flags & NodeFlags.Ambient)) {
|
||||
error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24
|
|||
interface C { }
|
||||
|
||||
declare module M {
|
||||
|
||||
|
||||
interface C1 { }
|
||||
~~
|
||||
!!! error TS2507: An interface cannot merge with a non-ambient class.
|
||||
|
@ -33,7 +33,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24
|
|||
interface C1 { }
|
||||
~~
|
||||
!!! error TS2507: An interface cannot merge with a non-ambient class.
|
||||
|
||||
|
||||
export class C2 { }
|
||||
~~
|
||||
!!! error TS2506: A non-ambient class cannot be merged with an interface.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
tests/cases/compiler/file1.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class.
|
||||
tests/cases/compiler/file1.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface.
|
||||
tests/cases/compiler/file1.ts(3,7): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/file1.ts(4,10): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/file1.ts(8,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/file1.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class.
|
||||
tests/cases/compiler/file1.ts(3,7): error TS2506: A non-ambient class cannot be merged with an interface.
|
||||
tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface.
|
||||
tests/cases/compiler/file2.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class.
|
||||
tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'.
|
||||
|
@ -12,6 +12,7 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'.
|
|||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (5 errors) ====
|
||||
|
||||
interface I { }
|
||||
~
|
||||
!!! error TS2507: An interface cannot merge with a non-ambient class.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//// [tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
interface I { }
|
||||
class C1 { }
|
||||
class C2 { }
|
||||
|
@ -74,3 +75,36 @@ var v = 3;
|
|||
var Foo;
|
||||
(function (Foo) {
|
||||
})(Foo || (Foo = {}));
|
||||
|
||||
|
||||
//// [file1.d.ts]
|
||||
interface I {
|
||||
}
|
||||
declare class C1 {
|
||||
}
|
||||
declare class C2 {
|
||||
}
|
||||
declare function f(): void;
|
||||
declare var v: number;
|
||||
declare class Foo {
|
||||
static x: number;
|
||||
}
|
||||
declare module N {
|
||||
module F {
|
||||
}
|
||||
}
|
||||
//// [file2.d.ts]
|
||||
declare class I {
|
||||
}
|
||||
interface C1 {
|
||||
}
|
||||
declare function C2(): void;
|
||||
declare class f {
|
||||
}
|
||||
declare var v: number;
|
||||
declare module Foo {
|
||||
var x: number;
|
||||
}
|
||||
declare module N {
|
||||
function F(): any;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue