Version 2.13.0-40.0.dev

Merge commit '4b4cc13ff5cbcbd57ccf64d56a8c143d07536d8c' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
index 1ee1ff8..b820eb7 100644
--- a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
@@ -4989,6 +4989,31 @@
 
   @override
   Type getDeclaredType(TypeOperations<Variable, Type> typeOperations) {
+    // Since we don't actually support property promotion, we just compute what
+    // promotions would have occurred if we *did* support it (for the purpose of
+    // issuing more useful error messages), we have some leeway in how we define
+    // the "declared type" of a property.  It's tempting to define it as the
+    // return type of the referenced getter, but this is problematic for two
+    // reasons: (1) we don't have the necessary hooks to ask the client what
+    // this type is, and (2) the referenced getter can become more specific due
+    // to the presence of other promotions, breaking the invariant that promoted
+    // types are expected to be subtypes of the declared type, e.g.:
+    //
+    //   abstract class C { num? get x; }
+    //   abstract class D extends C { int? get x; }
+    //   f(C c) {
+    //     if (c.x != null) { // "promotes" c.x to `num`
+    //       if (c is D) { // promotes c to D, so c.x now refers to an `int?`
+    //         // Invariant broken: `num` is not a subtype of `int?`
+    //       }
+    //     }
+    //   }
+    //
+    // Rather than break the invariant (which could lead to unexpected behaviors
+    // of flow analysis, including possibly crashes), it seems wiser to simply
+    // define the "declared type" for properties to be the top type; in practice
+    // this still produces useful results, and it doesn't violate soundness
+    // because we don't actually promote property references.
     return typeOperations.topType;
   }
 
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index 3521770..58ad7fc 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -328,6 +328,13 @@
           dataForTesting.flowAnalysisResult.nonPromotionReasons[expression] =
               nonPromotionReasonText;
         }
+        // Note: this will always pick the first viable reason (only).  I
+        // (paulberry) believe this is the one that will be the most relevant,
+        // but I need to do more testing to validate that.  I can't do that
+        // additional testing yet because at the moment we only handle failed
+        // promotions to non-nullable.
+        // TODO(paulberry): do more testing and then expand on the comment
+        // above.
         context = [message];
         break;
       }
diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt
index 69f280f..d977b3a 100644
--- a/pkg/front_end/test/spell_checking_list_code.txt
+++ b/pkg/front_end/test/spell_checking_list_code.txt
@@ -101,6 +101,7 @@
 became
 beforehand
 behave
+believe
 bellow
 belonging
 beloning
@@ -631,6 +632,7 @@
 lc
 ld
 leafp
+leeway
 len
 lets
 letting
@@ -1175,6 +1177,7 @@
 temp
 temporaries
 temps
+tempting
 term
 termcap
 terminator
@@ -1323,6 +1326,7 @@
 vegorov
 verbosity
 versa
+viable
 vice
 video
 violated
@@ -1355,6 +1359,7 @@
 wiki
 wikipedia
 wind
+wiser
 with1
 wn
 worthwhile
diff --git a/tools/VERSION b/tools/VERSION
index 9c16a52..b2b8996 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 39
+PRERELEASE 40
 PRERELEASE_PATCH 0
\ No newline at end of file