@@ -645,7 +645,7 @@ module ts {
645
645
}
646
646
647
647
// If symbol is directly available by its name in the symbol table
648
- if ( isAccessible ( symbols [ symbol . name ] ) ) {
648
+ if ( hasProperty ( symbols , symbol . name ) && isAccessible ( symbols [ symbol . name ] ) ) {
649
649
return symbol ;
650
650
}
651
651
@@ -668,7 +668,7 @@ module ts {
668
668
var qualify = false ;
669
669
forEachSymbolTableInScope ( enclosingDeclaration , symbolTable => {
670
670
// If symbol of this name is not available in the symbol table we are ok
671
- if ( ! symbolTable [ symbol . name ] ) {
671
+ if ( ! hasProperty ( symbolTable , symbol . name ) ) {
672
672
// Continue to the next symbol table
673
673
return false ;
674
674
}
@@ -693,8 +693,36 @@ module ts {
693
693
return qualify
694
694
}
695
695
696
- function isSymbolAccessible ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags ) : boolean {
697
- // TODO(shkamat): Actual implementation
696
+ function isSymbolAccessible ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags ) : SymbolAccessiblityResult {
697
+ if ( symbol && enclosingDeclaration && ! ( symbol . flags & SymbolFlags . TypeParameter ) ) {
698
+ var initialSymbol = symbol ;
699
+ var meaningToLook = meaning ;
700
+ while ( symbol ) {
701
+ // Symbol is accessible if it by itself is accessible
702
+ var accessibleSymbol = getAccessibleSymbol ( symbol , enclosingDeclaration , meaningToLook ) ;
703
+ if ( accessibleSymbol ) {
704
+ if ( forEach ( accessibleSymbol . declarations , declaration => ! isDeclarationVisible ( declaration ) ) ) {
705
+ return {
706
+ accessibility : SymbolAccessibility . NotAccessible ,
707
+ errorSymbolName : symbolToString ( initialSymbol , enclosingDeclaration , meaning ) ,
708
+ errorModuleName : symbol !== initialSymbol ? symbolToString ( symbol , enclosingDeclaration , SymbolFlags . Namespace ) : undefined
709
+ } ;
710
+ }
711
+ return { accessibility : SymbolAccessibility . Accessible } ;
712
+ }
713
+
714
+ meaningToLook = SymbolFlags . Namespace ;
715
+ symbol = symbol . parent ;
716
+ }
717
+
718
+ // This is a local symbol that cannot be named
719
+ return {
720
+ accessibility : SymbolAccessibility . CannotBeNamed ,
721
+ errorSymbolName : symbolToString ( initialSymbol , enclosingDeclaration , meaning ) ,
722
+ } ;
723
+ }
724
+
725
+ return { accessibility : SymbolAccessibility . Accessible } ;
698
726
}
699
727
700
728
// Enclosing declaration is optional when we dont want to get qualified name in the enclosing declaration scope
0 commit comments