Version 2.17.0-51.0.dev

Merge commit '5106605af6b941a81d8ad1534ea76cd08c3978de' into 'dev'
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index ad8e1da..1e84b07 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -1342,6 +1342,7 @@
     flow?.conditional_conditionBegin();
 
     // TODO(scheglov) Do we need these checks for null?
+    InferenceContext.setType(node.condition, typeProvider.boolType);
     condition.accept(this);
     condition = node.condition;
     var whyNotPromoted = flowAnalysis.flow?.whyNotPromoted(condition);
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
index 483d1dc..9c11a5e 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
@@ -15,6 +15,19 @@
 
 @reflectiveTest
 class UndefinedMethodTest extends PubPackageResolutionTest {
+  test_conditional_expression_condition_context() async {
+    await assertErrorsInCode('''
+T castObject<T>(Object value) => value as T;
+
+main() {
+  (castObject(true)..whatever()) ? 1 : 2;
+}
+''', [
+      error(CompileTimeErrorCode.UNDEFINED_METHOD, 76, 8,
+          messageContains: ["type 'bool'"]),
+    ]);
+  }
+
   test_constructor_defined() async {
     await assertNoErrorsInCode(r'''
 class C {
diff --git a/tests/language/bool/conditional_expression_condition_context_error_test.dart b/tests/language/bool/conditional_expression_condition_context_error_test.dart
new file mode 100644
index 0000000..ade91d5
--- /dev/null
+++ b/tests/language/bool/conditional_expression_condition_context_error_test.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+T castObject<T>(Object value) => value as T;
+
+main() {
+  print((castObject(true)..whatever()) ? 1 : 2);
+  //                       ^^^^^^^^
+  // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
+  // [cfe] The method 'whatever' isn't defined for the class 'bool'.
+}
diff --git a/tests/language_2/bool/conditional_expression_condition_context_error_test.dart b/tests/language_2/bool/conditional_expression_condition_context_error_test.dart
new file mode 100644
index 0000000..ade91d5
--- /dev/null
+++ b/tests/language_2/bool/conditional_expression_condition_context_error_test.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+T castObject<T>(Object value) => value as T;
+
+main() {
+  print((castObject(true)..whatever()) ? 1 : 2);
+  //                       ^^^^^^^^
+  // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
+  // [cfe] The method 'whatever' isn't defined for the class 'bool'.
+}
diff --git a/tools/VERSION b/tools/VERSION
index 35fba8c..f4bb13a 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 17
 PATCH 0
-PRERELEASE 50
+PRERELEASE 51
 PRERELEASE_PATCH 0
\ No newline at end of file