diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 75b2f72d53..8b18c2ce72 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -10984,7 +10984,7 @@ func (c *Checker) checkPrivateIdentifierPropertyAccess(leftType *Type, right *as return true } } - c.error(right, diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, scanner.DeclarationNameToString(typeClass.Name())) + c.error(right, diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, c.SymbolToString(typeClass.Symbol())) return true } return false diff --git a/internal/checker/relater.go b/internal/checker/relater.go index 4565655c73..350140daa7 100644 --- a/internal/checker/relater.go +++ b/internal/checker/relater.go @@ -11,7 +11,6 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/jsnum" - "github.com/microsoft/typescript-go/internal/scanner" ) type SignatureCheckMode uint32 @@ -4269,9 +4268,7 @@ func (r *Relater) reportUnmatchedProperty(source *Type, target *Type, unmatchedP privateIdentifierDescription := unmatchedProperty.ValueDeclaration.Name().Text() symbolTableKey := binder.GetSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription) if r.c.getPropertyOfType(source, symbolTableKey) != nil { - sourceName := scanner.DeclarationNameToString(ast.GetNameOfDeclaration(source.symbol.ValueDeclaration)) - targetName := scanner.DeclarationNameToString(ast.GetNameOfDeclaration(target.symbol.ValueDeclaration)) - r.reportError(diagnostics.Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2, privateIdentifierDescription, sourceName, targetName) + r.reportError(diagnostics.Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2, privateIdentifierDescription, r.c.SymbolToString(source.symbol), r.c.SymbolToString(target.symbol)) return } } diff --git a/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt index 6be1907e16..7b2e560cbf 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt @@ -1,5 +1,5 @@ -privateNameMethodClassExpression.ts(9,17): error TS18013: Property '#method' is not accessible outside class '(Missing)' because it has a private identifier. -privateNameMethodClassExpression.ts(10,17): error TS18013: Property '#field' is not accessible outside class '(Missing)' because it has a private identifier. +privateNameMethodClassExpression.ts(9,17): error TS18013: Property '#method' is not accessible outside class 'C' because it has a private identifier. +privateNameMethodClassExpression.ts(10,17): error TS18013: Property '#field' is not accessible outside class 'C' because it has a private identifier. ==== privateNameMethodClassExpression.ts (2 errors) ==== @@ -13,9 +13,9 @@ privateNameMethodClassExpression.ts(10,17): error TS18013: Property '#field' is console.log(C.getInstance().getField()); C.getInstance().#method; // Error ~~~~~~~ -!!! error TS18013: Property '#method' is not accessible outside class '(Missing)' because it has a private identifier. +!!! error TS18013: Property '#method' is not accessible outside class 'C' because it has a private identifier. C.getInstance().#field; // Error ~~~~~~ -!!! error TS18013: Property '#field' is not accessible outside class '(Missing)' because it has a private identifier. +!!! error TS18013: Property '#field' is not accessible outside class 'C' because it has a private identifier. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt.diff index e3a5c47f99..305b32c65c 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/privateNameMethodClassExpression.errors.txt.diff @@ -3,8 +3,8 @@ @@= skipped -0, +0 lines =@@ -privateNameMethodClassExpression.ts(9,17): error TS18013: Property '#method' is not accessible outside class '(anonymous)' because it has a private identifier. -privateNameMethodClassExpression.ts(10,17): error TS18013: Property '#field' is not accessible outside class '(anonymous)' because it has a private identifier. -+privateNameMethodClassExpression.ts(9,17): error TS18013: Property '#method' is not accessible outside class '(Missing)' because it has a private identifier. -+privateNameMethodClassExpression.ts(10,17): error TS18013: Property '#field' is not accessible outside class '(Missing)' because it has a private identifier. ++privateNameMethodClassExpression.ts(9,17): error TS18013: Property '#method' is not accessible outside class 'C' because it has a private identifier. ++privateNameMethodClassExpression.ts(10,17): error TS18013: Property '#field' is not accessible outside class 'C' because it has a private identifier. ==== privateNameMethodClassExpression.ts (2 errors) ==== @@ -13,10 +13,10 @@ C.getInstance().#method; // Error ~~~~~~~ -!!! error TS18013: Property '#method' is not accessible outside class '(anonymous)' because it has a private identifier. -+!!! error TS18013: Property '#method' is not accessible outside class '(Missing)' because it has a private identifier. ++!!! error TS18013: Property '#method' is not accessible outside class 'C' because it has a private identifier. C.getInstance().#field; // Error ~~~~~~ -!!! error TS18013: Property '#field' is not accessible outside class '(anonymous)' because it has a private identifier. -+!!! error TS18013: Property '#field' is not accessible outside class '(Missing)' because it has a private identifier. ++!!! error TS18013: Property '#field' is not accessible outside class 'C' because it has a private identifier. \ No newline at end of file