@@ -65,7 +65,8 @@ module ts {
6565 symbolToString : symbolToString ,
6666 getAugmentedPropertiesOfApparentType : getAugmentedPropertiesOfApparentType ,
6767 getRootSymbol : getRootSymbol ,
68- getContextualType : getContextualType
68+ getContextualType : getContextualType ,
69+ getFullyQualifiedName : getFullyQualifiedName
6970 } ;
7071
7172 var undefinedSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Transient , "undefined" ) ;
@@ -2431,7 +2432,7 @@ module ts {
24312432 case SyntaxKind . Identifier :
24322433 case SyntaxKind . QualifiedName :
24332434 var symbol = getSymbolInfo ( node ) ;
2434- return getDeclaredTypeOfSymbol ( symbol ) ;
2435+ return symbol && getDeclaredTypeOfSymbol ( symbol ) ;
24352436 default :
24362437 return unknownType ;
24372438 }
@@ -3471,41 +3472,6 @@ module ts {
34713472 return getAncestor ( node , kind ) !== undefined ;
34723473 }
34733474
3474- function getAncestor ( node : Node , kind : SyntaxKind ) : Node {
3475- switch ( kind ) {
3476- // special-cases that can be come first
3477- case SyntaxKind . ClassDeclaration :
3478- while ( node ) {
3479- switch ( node . kind ) {
3480- case SyntaxKind . ClassDeclaration :
3481- return < ClassDeclaration > node ;
3482- case SyntaxKind . EnumDeclaration :
3483- case SyntaxKind . InterfaceDeclaration :
3484- case SyntaxKind . ModuleDeclaration :
3485- case SyntaxKind . ImportDeclaration :
3486- // early exit cases - declarations cannot be nested in classes
3487- return undefined ;
3488- default :
3489- node = node . parent ;
3490- continue ;
3491- }
3492- }
3493- break ;
3494- default :
3495- while ( node ) {
3496- if ( node . kind === kind ) {
3497- return node ;
3498- }
3499- else {
3500- node = node . parent ;
3501- }
3502- }
3503- break ;
3504- }
3505-
3506- return undefined ;
3507- }
3508-
35093475 // EXPRESSION TYPE CHECKING
35103476
35113477 function checkIdentifier ( node : Identifier ) : Type {
@@ -3852,6 +3818,11 @@ module ts {
38523818 // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
38533819 // be "pushed" onto a node using the contextualType property.
38543820 function getContextualType ( node : Expression ) : Type {
3821+ if ( isInsideWithStatementBody ( node ) ) {
3822+ // We cannot answer semantic questions within a with block, do not proceed any further
3823+ return undefined ;
3824+ }
3825+
38553826 if ( node . contextualType ) {
38563827 return node . contextualType ;
38573828 }
@@ -6717,7 +6688,20 @@ module ts {
67176688 return findChildAtPosition ( sourceFile ) ;
67186689 }
67196690
6720- function getSymbolsInScope ( location : Node , meaning : SymbolFlags ) : Symbol [ ] {
6691+ function isInsideWithStatementBody ( node : Node ) : boolean {
6692+ if ( node ) {
6693+ while ( node . parent ) {
6694+ if ( node . parent . kind === SyntaxKind . WithStatement && ( < WithStatement > node . parent ) . statement === node ) {
6695+ return true ;
6696+ }
6697+ node = node . parent ;
6698+ }
6699+ }
6700+
6701+ return false ;
6702+ }
6703+
6704+ function getSymbolsInScope ( location : Node , meaning : SymbolFlags ) : Symbol [ ] {
67216705 var symbols : SymbolTable = { } ;
67226706 var memberFlags : NodeFlags = 0 ;
67236707 function copySymbol ( symbol : Symbol , meaning : SymbolFlags ) {
@@ -6737,6 +6721,12 @@ module ts {
67376721 }
67386722 }
67396723 }
6724+
6725+ if ( isInsideWithStatementBody ( location ) ) {
6726+ // We cannot answer semantic questions within a with block, do not proceed any further
6727+ return [ ] ;
6728+ }
6729+
67406730 while ( location ) {
67416731 if ( location . locals && ! isGlobalSourceFile ( location ) ) {
67426732 copySymbols ( location . locals , meaning ) ;
@@ -7009,6 +6999,11 @@ module ts {
70096999 }
70107000
70117001 function getSymbolInfo ( node : Node ) {
7002+ if ( isInsideWithStatementBody ( node ) ) {
7003+ // We cannot answer semantic questions within a with block, do not proceed any further
7004+ return undefined ;
7005+ }
7006+
70127007 if ( isDeclarationOrFunctionExpressionOrCatchVariableName ( node ) ) {
70137008 // This is a declaration, call getSymbolOfNode
70147009 return getSymbolOfNode ( node . parent ) ;
@@ -7063,9 +7058,15 @@ module ts {
70637058 }
70647059
70657060 function getTypeOfNode ( node : Node ) : Type {
7061+ if ( isInsideWithStatementBody ( node ) ) {
7062+ // We cannot answer semantic questions within a with block, do not proceed any further
7063+ return unknownType ;
7064+ }
7065+
70667066 if ( isExpression ( node ) ) {
70677067 return getTypeOfExpression ( < Expression > node ) ;
70687068 }
7069+
70697070 if ( isTypeNode ( node ) ) {
70707071 return getTypeFromTypeNode ( < TypeNode > node ) ;
70717072 }
@@ -7078,7 +7079,7 @@ module ts {
70787079
70797080 if ( isTypeDeclarationName ( node ) ) {
70807081 var symbol = getSymbolInfo ( node ) ;
7081- return getDeclaredTypeOfSymbol ( symbol ) ;
7082+ return symbol && getDeclaredTypeOfSymbol ( symbol ) ;
70827083 }
70837084
70847085 if ( isDeclaration ( node ) ) {
@@ -7089,12 +7090,12 @@ module ts {
70897090
70907091 if ( isDeclarationOrFunctionExpressionOrCatchVariableName ( node ) ) {
70917092 var symbol = getSymbolInfo ( node ) ;
7092- return getTypeOfSymbol ( symbol ) ;
7093+ return symbol && getTypeOfSymbol ( symbol ) ;
70937094 }
70947095
70957096 if ( isInRightSideOfImportOrExportAssignment ( node ) ) {
70967097 var symbol = getSymbolInfo ( node ) ;
7097- var declaredType = getDeclaredTypeOfSymbol ( symbol ) ;
7098+ var declaredType = symbol && getDeclaredTypeOfSymbol ( symbol ) ;
70987099 return declaredType !== unknownType ? declaredType : getTypeOfSymbol ( symbol ) ;
70997100 }
71007101
@@ -7146,7 +7147,7 @@ module ts {
71467147 }
71477148
71487149 function getRootSymbol ( symbol : Symbol ) {
7149- return ( symbol . flags & SymbolFlags . Transient ) ? getSymbolLinks ( symbol ) . target : symbol ;
7150+ return ( ( symbol . flags & SymbolFlags . Transient ) && getSymbolLinks ( symbol ) . target ) || symbol ;
71507151 }
71517152
71527153 // Emitter support
0 commit comments