Skip to content

Commit 8ab038f

Browse files
committed
Fixed the merge conflicts that went undetected in github
1 parent beef2eb commit 8ab038f

File tree

3 files changed

+50
-49
lines changed

3 files changed

+50
-49
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4318,7 +4318,7 @@ module ts {
43184318
function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) {
43194319
var type = getTypeOfSymbol(symbol);
43204320
// Only narrow when symbol is variable of a structured type
4321-
if (symbol.flags & SymbolFlags.Variable && type.flags & TypeFlags.Structured) {
4321+
if (node && (symbol.flags & SymbolFlags.Variable && type.flags & TypeFlags.Structured)) {
43224322
while (true) {
43234323
var child = node;
43244324
node = node.parent;

src/services/services.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,7 @@ module ts {
23102310
return undefined;
23112311
}
23122312

2313-
function createCompletionEntry(symbol: Symbol, typeChecker: TypeChecker): CompletionEntry {
2313+
function createCompletionEntry(symbol: Symbol, typeChecker: TypeChecker, location: Node): CompletionEntry {
23142314
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
23152315
// We would like to only show things that can be added after a dot, so for instance numeric properties can
23162316
// not be accessed with a dot (a.1 <- invalid)
@@ -2325,7 +2325,7 @@ module ts {
23252325
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
23262326
return {
23272327
name: displayName,
2328-
kind: getSymbolKind(symbol, typeChecker),
2328+
kind: getSymbolKind(symbol, typeChecker, location),
23292329
kindModifiers: getSymbolModifiers(symbol)
23302330
};
23312331
}
@@ -2396,6 +2396,7 @@ module ts {
23962396
};
23972397
host.log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart));
23982398

2399+
var location = getTouchingPropertyName(sourceFile, position);
23992400
// Populate the completion list
24002401
var semanticStart = new Date().getTime();
24012402
if (isRightOfDot) {
@@ -2477,7 +2478,7 @@ module ts {
24772478
function getCompletionEntriesFromSymbols(symbols: Symbol[], session: CompletionSession): void {
24782479
var start = new Date().getTime();
24792480
forEach(symbols, symbol => {
2480-
var entry = createCompletionEntry(symbol, session.typeChecker);
2481+
var entry = createCompletionEntry(symbol, session.typeChecker, location);
24812482
if (entry && !lookUp(session.symbols, entry.name)) {
24822483
session.entries.push(entry);
24832484
session.symbols[entry.name] = symbol;
@@ -2689,12 +2690,12 @@ module ts {
26892690

26902691
var symbol = lookUp(activeCompletionSession.symbols, entryName);
26912692
if (symbol) {
2692-
var completionEntry = createCompletionEntry(symbol, session.typeChecker);
2693+
var location = getTouchingPropertyName(sourceFile, position);
2694+
var completionEntry = createCompletionEntry(symbol, session.typeChecker, location);
26932695
// TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind'
26942696
// which is permissible given that it is backwards compatible; but really we should consider
26952697
// passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
26962698
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
2697-
var location = getTouchingPropertyName(sourceFile, position);
26982699
Debug.assert(session.typeChecker.getNarrowedTypeOfSymbol(symbol, location) !== undefined, "Could not find type for symbol");
26992700
var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), location, session.typeChecker, location, SemanticMeaning.All);
27002701
return {
@@ -2740,7 +2741,7 @@ module ts {
27402741
}
27412742

27422743
// TODO(drosen): use contextual SemanticMeaning.
2743-
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker): string {
2744+
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker, location?: Node): string {
27442745
var flags = symbol.getFlags();
27452746

27462747
if (flags & SymbolFlags.Class) return ScriptElementKind.classElement;
@@ -2749,7 +2750,7 @@ module ts {
27492750
if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement;
27502751
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
27512752

2752-
var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver);
2753+
var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location);
27532754
if (result === ScriptElementKind.unknown) {
27542755
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
27552756
if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement;
@@ -2759,7 +2760,7 @@ module ts {
27592760
return result;
27602761
}
27612762

2762-
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags, typeResolver: TypeChecker) {
2763+
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags, typeResolver: TypeChecker, location: Node) {
27632764
if (typeResolver.isUndefinedSymbol(symbol)) {
27642765
return ScriptElementKind.variableElement;
27652766
}
@@ -2794,7 +2795,7 @@ module ts {
27942795
if (!unionPropertyKind) {
27952796
// If this was union of all methods,
27962797
//make sure it has call signatures before we can label it as method
2797-
var typeOfUnionProperty = typeInfoResolver.getTypeOfSymbol(symbol);
2798+
var typeOfUnionProperty = typeInfoResolver.getNarrowedTypeOfSymbol(symbol, location);
27982799
if (typeOfUnionProperty.getCallSignatures().length) {
27992800
return ScriptElementKind.memberFunctionElement;
28002801
}
@@ -2858,7 +2859,7 @@ module ts {
28582859
var displayParts: SymbolDisplayPart[] = [];
28592860
var documentation: SymbolDisplayPart[];
28602861
var symbolFlags = symbol.flags;
2861-
var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver);
2862+
var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location);
28622863
var hasAddedSymbolInfo: boolean;
28632864
// Class at constructor site need to be shown as constructor apart from property,method, vars
28642865
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Import) {
@@ -3113,7 +3114,7 @@ module ts {
31133114
}
31143115
}
31153116
else {
3116-
symbolKind = getSymbolKind(symbol, typeResolver);
3117+
symbolKind = getSymbolKind(symbol, typeResolver, location);
31173118
}
31183119
}
31193120

tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(14,5): error TS2323: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; } | { prop: number; }'.
1+
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(14,5): error TS2322: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; } | { prop: number; }'.
22
Type '{ prop: string | number; }' is not assignable to type '{ prop: number; }'.
33
Types of property 'prop' are incompatible.
44
Type 'string | number' is not assignable to type 'number'.
55
Type 'string' is not assignable to type 'number'.
6-
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(20,5): error TS2323: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
6+
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(20,5): error TS2322: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
77
Type '{ prop: string | number; }' is not assignable to type '{ prop: number; }'.
88
Types of property 'prop' are incompatible.
99
Type 'string | number' is not assignable to type 'number'.
1010
Type 'string' is not assignable to type 'number'.
11-
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(21,5): error TS2323: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
11+
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(21,5): error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
1212
Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; }'.
1313
Types of property 'prop' are incompatible.
1414
Type 'string | number' is not assignable to type 'number'.
1515
Type 'string' is not assignable to type 'number'.
16-
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(25,5): error TS2323: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
16+
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(25,5): error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
1717
Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; anotherP1: number; }'.
1818
Types of property 'prop' are incompatible.
1919
Type 'string | number' is not assignable to type 'number'.
2020
Type 'string' is not assignable to type 'number'.
21-
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(29,5): error TS2323: Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
21+
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(29,5): error TS2322: Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
2222
Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: number; anotherP1: number; }'.
2323
Types of property 'prop' are incompatible.
2424
Type 'string | number' is not assignable to type 'number'.
2525
Type 'string' is not assignable to type 'number'.
26-
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(57,5): error TS2323: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I11 | I21'.
26+
tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(57,5): error TS2322: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I11 | I21'.
2727
Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I21'.
2828
Types of property 'commonMethodDifferentReturnType' are incompatible.
2929
Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'.
@@ -47,50 +47,50 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(
4747
// Since T is union Type we only allow the assignment of either object with property of type string or object with property of type number but do not allow object with property of type string | number
4848
var objStrOrNum3: { prop: string } | { prop: number } = {
4949
~~~~~~~~~~~~
50-
!!! error TS2323: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; } | { prop: number; }'.
51-
!!! error TS2323: Type '{ prop: string | number; }' is not assignable to type '{ prop: number; }'.
52-
!!! error TS2323: Types of property 'prop' are incompatible.
53-
!!! error TS2323: Type 'string | number' is not assignable to type 'number'.
54-
!!! error TS2323: Type 'string' is not assignable to type 'number'.
50+
!!! error TS2322: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; } | { prop: number; }'.
51+
!!! error TS2322: Type '{ prop: string | number; }' is not assignable to type '{ prop: number; }'.
52+
!!! error TS2322: Types of property 'prop' are incompatible.
53+
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
54+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
5555
prop: strOrNumber
5656
};
5757
var objStrOrNum4: { prop: string | number } = {
5858
prop: strOrNumber
5959
};
6060
var objStrOrNum5: { prop: string; anotherP: string; } | { prop: number } = { prop: strOrNumber };
6161
~~~~~~~~~~~~
62-
!!! error TS2323: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
63-
!!! error TS2323: Type '{ prop: string | number; }' is not assignable to type '{ prop: number; }'.
64-
!!! error TS2323: Types of property 'prop' are incompatible.
65-
!!! error TS2323: Type 'string | number' is not assignable to type 'number'.
66-
!!! error TS2323: Type 'string' is not assignable to type 'number'.
62+
!!! error TS2322: Type '{ prop: string | number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
63+
!!! error TS2322: Type '{ prop: string | number; }' is not assignable to type '{ prop: number; }'.
64+
!!! error TS2322: Types of property 'prop' are incompatible.
65+
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
66+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
6767
var objStrOrNum6: { prop: string; anotherP: string; } | { prop: number } = {
6868
~~~~~~~~~~~~
69-
!!! error TS2323: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
70-
!!! error TS2323: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; }'.
71-
!!! error TS2323: Types of property 'prop' are incompatible.
72-
!!! error TS2323: Type 'string | number' is not assignable to type 'number'.
73-
!!! error TS2323: Type 'string' is not assignable to type 'number'.
69+
!!! error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; }'.
70+
!!! error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; }'.
71+
!!! error TS2322: Types of property 'prop' are incompatible.
72+
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
73+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
7474
prop: strOrNumber,
7575
anotherP: str
7676
};
7777
var objStrOrNum7: { prop: string; anotherP: string; } | { prop: number; anotherP1: number } = {
7878
~~~~~~~~~~~~
79-
!!! error TS2323: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
80-
!!! error TS2323: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; anotherP1: number; }'.
81-
!!! error TS2323: Types of property 'prop' are incompatible.
82-
!!! error TS2323: Type 'string | number' is not assignable to type 'number'.
83-
!!! error TS2323: Type 'string' is not assignable to type 'number'.
79+
!!! error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
80+
!!! error TS2322: Type '{ prop: string | number; anotherP: string; }' is not assignable to type '{ prop: number; anotherP1: number; }'.
81+
!!! error TS2322: Types of property 'prop' are incompatible.
82+
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
83+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
8484
prop: strOrNumber,
8585
anotherP: str
8686
};
8787
var objStrOrNum8: { prop: string; anotherP: string; } | { prop: number; anotherP1: number } = {
8888
~~~~~~~~~~~~
89-
!!! error TS2323: Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
90-
!!! error TS2323: Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: number; anotherP1: number; }'.
91-
!!! error TS2323: Types of property 'prop' are incompatible.
92-
!!! error TS2323: Type 'string | number' is not assignable to type 'number'.
93-
!!! error TS2323: Type 'string' is not assignable to type 'number'.
89+
!!! error TS2322: Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: string; anotherP: string; } | { prop: number; anotherP1: number; }'.
90+
!!! error TS2322: Type '{ prop: string | number; anotherP: string; anotherP1: number; }' is not assignable to type '{ prop: number; anotherP1: number; }'.
91+
!!! error TS2322: Types of property 'prop' are incompatible.
92+
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
93+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
9494
prop: strOrNumber,
9595
anotherP: str,
9696
anotherP1: num
@@ -120,11 +120,11 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(
120120
var strOrNumber: string | number;
121121
var i11Ori21: I11 | I21 = { // Like i1 and i2 both
122122
~~~~~~~~
123-
!!! error TS2323: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I11 | I21'.
124-
!!! error TS2323: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I21'.
125-
!!! error TS2323: Types of property 'commonMethodDifferentReturnType' are incompatible.
126-
!!! error TS2323: Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'.
127-
!!! error TS2323: Type 'string | number' is not assignable to type 'number'.
128-
!!! error TS2323: Type 'string' is not assignable to type 'number'.
123+
!!! error TS2322: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I11 | I21'.
124+
!!! error TS2322: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I21'.
125+
!!! error TS2322: Types of property 'commonMethodDifferentReturnType' are incompatible.
126+
!!! error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'.
127+
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
128+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
129129
commonMethodDifferentReturnType: (a, b) => strOrNumber,
130130
};

0 commit comments

Comments
 (0)