Skip to content

Commit

Permalink
[element model] migrate body_inference_context
Browse files Browse the repository at this point in the history
Change-Id: Ib5021c597c174903584a367e730af2a127915423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402143
Reviewed-by: Brian Wilkerson <[email protected]>
  • Loading branch information
pq committed Dec 20, 2024
1 parent 8a08c1b commit b79f187
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion pkg/analyzer/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ lib/src/dart/resolver/applicable_extensions.dart
lib/src/dart/resolver/assignment_expression_resolver.dart
lib/src/dart/resolver/ast_rewrite.dart
lib/src/dart/resolver/binary_expression_resolver.dart
lib/src/dart/resolver/body_inference_context.dart
lib/src/dart/resolver/comment_reference_resolver.dart
lib/src/dart/resolver/constructor_reference_resolver.dart
lib/src/dart/resolver/extension_member_resolver.dart
Expand Down
14 changes: 7 additions & 7 deletions pkg/analyzer/lib/src/dart/resolver/body_inference_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
Expand Down Expand Up @@ -79,8 +79,8 @@ class BodyInferenceContext {

if (isGenerator) {
var requiredClass = isAsynchronous
? _typeProvider.streamElement
: _typeProvider.iterableElement;
? _typeProvider.streamElement2
: _typeProvider.iterableElement2;
var type = _argumentOf(expressionType, requiredClass);
if (type != null) {
_returnTypes.add(type);
Expand Down Expand Up @@ -157,8 +157,8 @@ class BodyInferenceContext {
return _returnTypes.fold(initialType, _typeSystem.leastUpperBound);
}

static DartType? _argumentOf(DartType type, InterfaceElement element) {
var elementType = type.asInstanceOf(element);
static DartType? _argumentOf(DartType type, InterfaceElement2 element) {
var elementType = type.asInstanceOf2(element);
if (elementType != null) {
return elementType.typeArguments[0];
}
Expand Down Expand Up @@ -186,7 +186,7 @@ class BodyInferenceContext {
if (node.isGenerator && node.isAsynchronous) {
var elementType = _argumentOf(
imposedType,
typeSystem.typeProvider.streamElement,
typeSystem.typeProvider.streamElement2,
);
if (elementType != null) {
return elementType;
Expand All @@ -199,7 +199,7 @@ class BodyInferenceContext {
if (node.isGenerator && node.isSynchronous) {
var elementType = _argumentOf(
imposedType,
typeSystem.typeProvider.iterableElement,
typeSystem.typeProvider.iterableElement2,
);
if (elementType != null) {
return elementType;
Expand Down

0 comments on commit b79f187

Please sign in to comment.