mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:39:38 +00:00
analyzer: Support operators in extension on a type variable type
Fixes https://github.com/dart-lang/sdk/issues/54462 Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try Change-Id: If0c2a29559d86830434ae9c68ae1f0da72380741 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372840 Commit-Queue: Sam Rawlins <srawlins@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
87ca13f90a
commit
89d9912790
|
@ -407,7 +407,6 @@ class BinaryExpressionResolver {
|
|||
}
|
||||
|
||||
var leftType = leftOperand.typeOrThrow;
|
||||
leftType = _typeSystem.resolveToBound(leftType);
|
||||
|
||||
if (identical(leftType, NeverTypeImpl.instance)) {
|
||||
_resolver.errorReporter.atNode(
|
||||
|
|
|
@ -1788,6 +1788,35 @@ BinaryExpression
|
|||
''');
|
||||
}
|
||||
|
||||
test_plus_int_typeVariable_via_extension() async {
|
||||
await assertNoErrorsInCode('''
|
||||
class Foo {}
|
||||
|
||||
extension FooExtension<F extends Foo> on F {
|
||||
F operator +(int i) => this;
|
||||
|
||||
F get gg => this + 1;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('this + 1'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: ThisExpression
|
||||
thisKeyword: this
|
||||
staticType: F
|
||||
operator: +
|
||||
rightOperand: IntegerLiteral
|
||||
literal: 1
|
||||
parameter: root::@parameter::i
|
||||
staticType: int
|
||||
staticElement: MethodMember
|
||||
base: self::@extension::FooExtension::@method::+
|
||||
substitution: {F: F}
|
||||
staticInvokeType: F Function(int)
|
||||
staticType: F
|
||||
''');
|
||||
}
|
||||
|
||||
test_plus_invalidType_int() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f() {
|
||||
|
|
Loading…
Reference in a new issue