@@ -3825,24 +3825,16 @@ module ts {
3825
3825
var start = range . pos ;
3826
3826
var end = range . end ;
3827
3827
var length = end - start ;
3828
-
3828
+
3829
3829
if ( ! matchResult ) {
3830
3830
errorAtPos ( start , length , Diagnostics . Invalid_reference_directive_syntax ) ;
3831
3831
}
3832
3832
else {
3833
- var referenceFilename = matchResult [ 3 ] ;
3834
- var basePath = getDirectoryPath ( file . filename ) ;
3835
- var referenceFullPath = normalizePath ( combinePaths ( basePath , referenceFilename ) ) ;
3836
- if ( file . filename . toLocaleLowerCase ( ) === referenceFullPath . toLocaleLowerCase ( ) ) {
3837
- errorAtPos ( start , length , Diagnostics . A_file_cannot_have_a_reference_to_itself ) ;
3838
- }
3839
- else {
3840
- referencedFiles . push ( {
3841
- pos : start ,
3842
- end : end ,
3843
- filename : referenceFilename
3844
- } ) ;
3845
- }
3833
+ referencedFiles . push ( {
3834
+ pos : start ,
3835
+ end : end ,
3836
+ filename : matchResult [ 3 ]
3837
+ } ) ;
3846
3838
}
3847
3839
}
3848
3840
}
@@ -3957,6 +3949,9 @@ module ts {
3957
3949
else if ( ! findSourceFile ( filename , isDefaultLib , refFile , refPos , refEnd ) ) {
3958
3950
diagnostic = Diagnostics . File_0_not_found ;
3959
3951
}
3952
+ else if ( refFile && host . getCanonicalFileName ( filename ) === host . getCanonicalFileName ( refFile . filename ) ) {
3953
+ diagnostic = Diagnostics . A_file_cannot_have_a_reference_to_itself ;
3954
+ }
3960
3955
}
3961
3956
else {
3962
3957
if ( ! ( findSourceFile ( filename + ".ts" , isDefaultLib , refFile , refPos , refEnd ) || findSourceFile ( filename + ".d.ts" , isDefaultLib , refFile , refPos , refEnd ) ) ) {
@@ -4015,7 +4010,7 @@ module ts {
4015
4010
4016
4011
function processReferencedFiles ( file : SourceFile , basePath : string ) {
4017
4012
forEach ( file . referencedFiles , ref => {
4018
- processSourceFile ( normalizePath ( combinePaths ( basePath , ref . filename ) ) , /* isDefaultLib */ false , file , ref . pos , ref . end ) ;
4013
+ processSourceFile ( normalizePath ( combinePaths ( basePath , ref . filename ) ) , /* isDefaultLib */ false , file , ref . pos , ref . end ) ;
4019
4014
} ) ;
4020
4015
}
4021
4016
0 commit comments