@@ -679,7 +679,7 @@ Fragment StreamingFlowGraphBuilder::BuildFunctionBody(
679679 } else if (dart_function.is_external ()) {
680680 body += ThrowNoSuchMethodError (TokenPosition::kNoSource , dart_function,
681681 /* incompatible_arguments=*/ false );
682- body += ThrowException (TokenPosition:: kNoSource ); // Close graph.
682+ ASSERT ( body. is_closed ());
683683 } else if (has_body) {
684684 body += BuildStatement ();
685685 }
@@ -1699,10 +1699,6 @@ Fragment StreamingFlowGraphBuilder::StringInterpolateSingle(
16991699 return flow_graph_builder_->StringInterpolateSingle (position);
17001700}
17011701
1702- Fragment StreamingFlowGraphBuilder::ThrowTypeError () {
1703- return flow_graph_builder_->ThrowTypeError ();
1704- }
1705-
17061702Fragment StreamingFlowGraphBuilder::LoadInstantiatorTypeArguments () {
17071703 return flow_graph_builder_->LoadInstantiatorTypeArguments ();
17081704}
@@ -2113,7 +2109,7 @@ Fragment StreamingFlowGraphBuilder::BuildVariableGetImpl(
21132109 already_assigned += flow_graph_builder_->ThrowLateInitializationError (
21142110 position, " _throwLocalAssignedDuringInitialization" ,
21152111 variable->name ());
2116- already_assigned += Goto (join );
2112+ ASSERT ( already_assigned. is_closed () );
21172113 }
21182114 } else {
21192115 // Late non-final variable. Store the initializer result.
@@ -2126,7 +2122,7 @@ Fragment StreamingFlowGraphBuilder::BuildVariableGetImpl(
21262122 Fragment initialize (is_uninitialized);
21272123 initialize += flow_graph_builder_->ThrowLateInitializationError (
21282124 position, " _throwLocalNotInitialized" , variable->name ());
2129- initialize += Goto (join );
2125+ ASSERT ( initialize. is_closed () );
21302126 }
21312127 }
21322128
@@ -2193,7 +2189,7 @@ Fragment StreamingFlowGraphBuilder::BuildVariableSetImpl(
21932189 Fragment already_initialized (is_initialized);
21942190 already_initialized += flow_graph_builder_->ThrowLateInitializationError (
21952191 position, " _throwLocalAlreadyInitialized" , variable->name ());
2196- already_initialized += Goto (join );
2192+ ASSERT ( already_initialized. is_closed () );
21972193 }
21982194
21992195 instructions = Fragment (instructions.entry , join);
@@ -4641,11 +4637,6 @@ Fragment StreamingFlowGraphBuilder::BuildAssertStatement(
46414637 Class::ZoneHandle (Z, Library::LookupCoreClass (Symbols::AssertionError ()));
46424638 ASSERT (!klass.IsNull ());
46434639
4644- // Build equivalent of `throw _AssertionError._throwNew(start, end, message)`
4645- // expression. We build throw (even through _throwNew already throws) because
4646- // call is not a valid last instruction for the block. Blocks can only
4647- // terminate with explicit control flow instructions (Branch, Goto, Return
4648- // or Throw).
46494640 Fragment otherwise_fragment (otherwise);
46504641 if (CompilerState::Current ().is_aot ()) {
46514642 // When in AOT, figure out start line, end line, line fragment needed for
@@ -4701,8 +4692,8 @@ Fragment StreamingFlowGraphBuilder::BuildAssertStatement(
47014692 otherwise_fragment +=
47024693 StaticCall (condition_start_offset, target, 3 , ICData::kStatic );
47034694 }
4704- otherwise_fragment += ThrowException (TokenPosition::kNoSource );
47054695 otherwise_fragment += Drop ();
4696+ ASSERT (otherwise_fragment.is_closed ());
47064697
47074698 return Fragment (instructions.entry , then);
47084699}
@@ -4982,16 +4973,9 @@ Fragment StreamingFlowGraphBuilder::BuildSwitchCase(SwitchHelper* helper,
49824973 body_fragment += Drop ();
49834974 }
49844975
4985- // TODO(http://dartbug.com/50595): The CFE does not insert breaks for
4986- // unterminated cases which never reach the end of their control flow.
4987- // If the CFE inserts synthesized breaks, we can add an assert here instead.
49884976 if (!is_default && body_fragment.is_open () &&
49894977 (case_index < (helper->case_count () - 1 ))) {
4990- const auto & error =
4991- String::ZoneHandle (Z, Symbols::New (thread (), " Unreachable code." ));
4992- body_fragment += Constant (error);
4993- body_fragment += ThrowException (TokenPosition::kNoSource );
4994- body_fragment += Drop ();
4978+ body_fragment += B->Stop (" Unreachable end of case" );
49954979 }
49964980
49974981 // If there is an implicit fall-through we have one [SwitchCase] and
0 commit comments