Skip to content

Commit 6970f35

Browse files
committed
build(cross): Nullable tuple handling
1 parent 0f40350 commit 6970f35

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

src.compiler/csharp/CSharpAstPrinter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ export default class CSharpAstPrinter extends AstPrinterBase {
864864

865865
protected writeNonNullExpression(expr: cs.NonNullExpression) {
866866
this.writeExpression(expr.expression);
867-
if (!cs.isNonNullExpression(expr)) {
867+
if (!cs.isNonNullExpression(expr.expression)) {
868868
this.write('!');
869869
}
870870
}

src.compiler/csharp/CSharpAstTransformer.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,11 +3217,18 @@ export default class CSharpAstTransformer {
32173217

32183218
csExpr.type = this._context.makeArrayTupleType(csExpr, []);
32193219

3220-
const tupleType = this._context.typeChecker.getContextualType(expression) ?? type;
3220+
let tupleType = this._context.typeChecker.getContextualType(expression);
3221+
let typeArgs = tupleType
3222+
? this._context.typeChecker.getTypeArguments(tupleType as ts.TypeReference)
3223+
: undefined;
3224+
if (!typeArgs || typeArgs.length !== expression.elements.length) {
3225+
tupleType = type;
3226+
typeArgs = this._context.typeChecker.getTypeArguments(tupleType as ts.TypeReference);
3227+
}
32213228

3222-
(csExpr.type as cs.ArrayTupleNode).types = this._context.typeChecker
3223-
.getTypeArguments(tupleType as ts.TypeReference)
3224-
.map((p, i) => this.createUnresolvedTypeNode(csExpr.type, expression.elements[i], p));
3229+
(csExpr.type as cs.ArrayTupleNode).types = typeArgs!.map((p, i) =>
3230+
this.createUnresolvedTypeNode(csExpr.type, expression.elements[i], p)
3231+
);
32253232

32263233
for (const e of expression.elements) {
32273234
const ex = this.visitExpression(csExpr, e);

src.compiler/csharp/CSharpEmitterContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,10 @@ export default class CSharpEmitterContext {
656656
}
657657
}
658658
break;
659+
case cs.SyntaxKind.ArrayTupleNode:
660+
return true;
659661
}
662+
660663
}
661664
return false;
662665
}
@@ -1759,7 +1762,7 @@ export default class CSharpEmitterContext {
17591762
return true;
17601763
}
17611764

1762-
return this.isEnum(tsType);
1765+
return this.isEnum(tsType) || this.typeChecker.isTupleType(tsType);
17631766
}
17641767

17651768
public isEnum(tsType: ts.Type) {

src.compiler/kotlin/KotlinEmitterContext.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ export default class KotlinEmitterContext extends CSharpEmitterContext {
6969
return undefined;
7070
}
7171

72+
protected isCsValueType(mapValueType: cs.TypeNode | null): boolean {
73+
if(mapValueType?.nodeType === cs.SyntaxKind.ArrayTupleNode) {
74+
return false;
75+
}
76+
return super.isCsValueType(mapValueType);
77+
}
78+
7279
public override getMethodNameFromSymbol(symbol: ts.Symbol): string {
7380
const parent = 'parent' in symbol ? (symbol.parent as ts.Symbol) : undefined;
7481

src/importer/MusicXmlImporter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,8 +2353,8 @@ export class MusicXmlImporter extends ScoreImporter {
23532353
}
23542354

23552355
if(this._keyAllStaves != null) {
2356-
newBar.keySignature = this._keyAllStaves[0];
2357-
newBar.keySignatureType = this._keyAllStaves[1];
2356+
newBar.keySignature = this._keyAllStaves![0];
2357+
newBar.keySignatureType = this._keyAllStaves![1];
23582358
}
23592359

23602360
for (let i = 0; i < voiceCount; i++) {

0 commit comments

Comments
 (0)