Skip to content

[refactoring] move Token.ASTERISK_ASTERISK to general group in resolveBinaryExpression #2114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1957,30 +1957,7 @@ export class Resolver extends DiagnosticEmitter {
case Token.MINUS:
case Token.ASTERISK:
case Token.SLASH:
case Token.PERCENT: { // mod has special logic, but also behaves like this
let leftType = this.resolveExpression(left, ctxFlow, ctxType, reportMode);
if (!leftType) return null;
let classReference = leftType.getClassOrWrapper(this.program);
if (classReference) {
let overload = classReference.lookupOverload(OperatorKind.fromBinaryToken(operator));
if (overload) return overload.signature.returnType;
}
let rightType = this.resolveExpression(right, ctxFlow, leftType, reportMode);
if (!rightType) return null;
let commonType = Type.commonDenominator(leftType, rightType, false);
if (!commonType) {
if (reportMode == ReportMode.REPORT) {
this.error(
DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,
node.range, leftType.toString(), rightType.toString()
);
}
}
return commonType;
}

// pow: result is common type of LHS and RHS, preferring overloads

case Token.PERCENT: // mod has special logic, but also behaves like this
case Token.ASTERISK_ASTERISK: {
let leftType = this.resolveExpression(left, ctxFlow, ctxType, reportMode);
if (!leftType) return null;
Expand Down