mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 12:57:42 +00:00
Deprecate CatchClause.exceptionParameter2/stackTraceParameter2
Change-Id: I3f0ae9367f35fe514a125cb0f06ccbdc8fa0dc18 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262502 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
8faa2fa4fd
commit
fcc9473dab
|
@ -393,8 +393,8 @@ class FeatureComputer {
|
|||
}
|
||||
}
|
||||
} else if (node is CatchClause) {
|
||||
if (node.exceptionParameter2?.declaredElement == variable ||
|
||||
node.stackTraceParameter2?.declaredElement == variable) {
|
||||
if (node.exceptionParameter?.declaredElement == variable ||
|
||||
node.stackTraceParameter?.declaredElement == variable) {
|
||||
return distance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1013,7 +1013,7 @@ class StatementCompletionProcessor {
|
|||
var struct = _KeywordConditionBlockStructure(
|
||||
catchKeyword,
|
||||
catchNode.leftParenthesis!,
|
||||
catchNode.exceptionParameter2!,
|
||||
catchNode.exceptionParameter!,
|
||||
catchNode.rightParenthesis!,
|
||||
catchNode.body);
|
||||
if (sb != null) {
|
||||
|
|
|
@ -26,12 +26,12 @@ class ConvertToOnType extends CorrectionProducer {
|
|||
var rightParenthesis = catchClause.rightParenthesis;
|
||||
if (catchKeyword != null &&
|
||||
catchClause.exceptionType == null &&
|
||||
catchClause.exceptionParameter2 == exceptionParameter &&
|
||||
catchClause.exceptionParameter == exceptionParameter &&
|
||||
rightParenthesis != null) {
|
||||
var exceptionTypeName = exceptionParameter.name;
|
||||
fixArguments.add(exceptionTypeName);
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
var stackTraceParameter = catchClause.stackTraceParameter2;
|
||||
var stackTraceParameter = catchClause.stackTraceParameter;
|
||||
if (stackTraceParameter != null) {
|
||||
builder.addSimpleReplacement(
|
||||
range.startStart(catchKeyword, stackTraceParameter),
|
||||
|
|
|
@ -39,7 +39,7 @@ class RemoveUnusedCatchClause extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
|
||||
if (catchClause.exceptionParameter2 == exceptionParameter) {
|
||||
if (catchClause.exceptionParameter == exceptionParameter) {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addDeletion(range.startStart(catchKeyword, catchClause.body));
|
||||
});
|
||||
|
|
|
@ -34,12 +34,12 @@ class RemoveUnusedCatchStack extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
|
||||
final exceptionParameter = catchClause.exceptionParameter2;
|
||||
final exceptionParameter = catchClause.exceptionParameter;
|
||||
if (exceptionParameter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (catchClause.stackTraceParameter2 == stackTraceParameter) {
|
||||
if (catchClause.stackTraceParameter == stackTraceParameter) {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addDeletion(
|
||||
range.endEnd(exceptionParameter, stackTraceParameter),
|
||||
|
|
|
@ -157,7 +157,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
for (var catchClause in catchClauses) {
|
||||
if (firstSelectedNode == catchClause ||
|
||||
firstSelectedNode == catchClause.body ||
|
||||
firstSelectedNode == catchClause.exceptionParameter2) {
|
||||
firstSelectedNode == catchClause.exceptionParameter) {
|
||||
invalidSelection(
|
||||
'Selection must either cover whole try statement or parts of try, catch, or finally block.');
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ class VisibleRangesComputer extends GeneralizingAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitCatchClause(CatchClause node) {
|
||||
_addLocalVariable(node, node.exceptionParameter2?.declaredElement);
|
||||
_addLocalVariable(node, node.stackTraceParameter2?.declaredElement);
|
||||
_addLocalVariable(node, node.exceptionParameter?.declaredElement);
|
||||
_addLocalVariable(node, node.stackTraceParameter?.declaredElement);
|
||||
node.body.accept(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -294,8 +294,8 @@ class CodeShapeDataCollector extends RecursiveAstVisitor<void> {
|
|||
void visitCatchClause(CatchClause node) {
|
||||
_visitChildren(node, {
|
||||
'exceptionType': node.exceptionType,
|
||||
'exceptionParameter': node.exceptionParameter2,
|
||||
'stackTraceParameter': node.stackTraceParameter2,
|
||||
'exceptionParameter': node.exceptionParameter,
|
||||
'stackTraceParameter': node.stackTraceParameter,
|
||||
'body': node.body,
|
||||
});
|
||||
super.visitCatchClause(node);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
## 5.2.0-dev
|
||||
* Deprecated `Element.enclosingElement3`, use `enclosingElement` instead.
|
||||
* Deprecated `Directive.element2`, use `element` instead.
|
||||
* Deprecated `CatchClause.exceptionParameter2`, use `exceptionParameter` instead.
|
||||
* Deprecated `CatchClause.stackTraceParameter2`, use `stackTraceParameter` instead.
|
||||
|
||||
## 5.1.0
|
||||
* Deprecated `AstNode.name2`, use `name` instead.
|
||||
|
|
|
@ -924,6 +924,11 @@ abstract class CatchClause implements AstNode {
|
|||
|
||||
/// Return the parameter whose value will be the exception that was thrown, or
|
||||
/// `null` if there is no 'catch' keyword.
|
||||
CatchClauseParameter? get exceptionParameter;
|
||||
|
||||
/// Return the parameter whose value will be the exception that was thrown, or
|
||||
/// `null` if there is no 'catch' keyword.
|
||||
@Deprecated('Use exceptionParameter instead')
|
||||
CatchClauseParameter? get exceptionParameter2;
|
||||
|
||||
/// Return the type of exceptions caught by this catch clause, or `null` if
|
||||
|
@ -942,6 +947,11 @@ abstract class CatchClause implements AstNode {
|
|||
|
||||
/// Return the parameter whose value will be the stack trace associated with
|
||||
/// the exception, or `null` if there is no stack trace parameter.
|
||||
CatchClauseParameter? get stackTraceParameter;
|
||||
|
||||
/// Return the parameter whose value will be the stack trace associated with
|
||||
/// the exception, or `null` if there is no stack trace parameter.
|
||||
@Deprecated('Use stackTraceParameter instead')
|
||||
CatchClauseParameter? get stackTraceParameter2;
|
||||
}
|
||||
|
||||
|
|
|
@ -1654,15 +1654,21 @@ class CatchClauseImpl extends AstNodeImpl implements CatchClause {
|
|||
Token get endToken => _body.endToken;
|
||||
|
||||
@override
|
||||
CatchClauseParameterImpl? get exceptionParameter2 {
|
||||
CatchClauseParameterImpl? get exceptionParameter {
|
||||
return _exceptionParameter;
|
||||
}
|
||||
|
||||
set exceptionParameter2(CatchClauseParameterImpl? parameter) {
|
||||
set exceptionParameter(CatchClauseParameterImpl? parameter) {
|
||||
_exceptionParameter = parameter;
|
||||
_becomeParentOf(parameter);
|
||||
}
|
||||
|
||||
@Deprecated('Use exceptionParameter instead')
|
||||
@override
|
||||
CatchClauseParameterImpl? get exceptionParameter2 {
|
||||
return exceptionParameter;
|
||||
}
|
||||
|
||||
@override
|
||||
TypeAnnotationImpl? get exceptionType => _exceptionType;
|
||||
|
||||
|
@ -1671,24 +1677,30 @@ class CatchClauseImpl extends AstNodeImpl implements CatchClause {
|
|||
}
|
||||
|
||||
@override
|
||||
CatchClauseParameterImpl? get stackTraceParameter2 {
|
||||
CatchClauseParameterImpl? get stackTraceParameter {
|
||||
return _stackTraceParameter;
|
||||
}
|
||||
|
||||
set stackTraceParameter2(CatchClauseParameterImpl? parameter) {
|
||||
set stackTraceParameter(CatchClauseParameterImpl? parameter) {
|
||||
_stackTraceParameter = parameter;
|
||||
_becomeParentOf(parameter);
|
||||
}
|
||||
|
||||
@Deprecated('Use stackTraceParameter instead')
|
||||
@override
|
||||
CatchClauseParameterImpl? get stackTraceParameter2 {
|
||||
return stackTraceParameter;
|
||||
}
|
||||
|
||||
@override
|
||||
ChildEntities get _childEntities => ChildEntities()
|
||||
..addToken('onKeyword', onKeyword)
|
||||
..addNode('exceptionType', exceptionType)
|
||||
..addToken('catchKeyword', catchKeyword)
|
||||
..addToken('leftParenthesis', leftParenthesis)
|
||||
..addNode('exceptionParameter', exceptionParameter2)
|
||||
..addNode('exceptionParameter', exceptionParameter)
|
||||
..addToken('comma', comma)
|
||||
..addNode('stackTraceParameter', stackTraceParameter2)
|
||||
..addNode('stackTraceParameter', stackTraceParameter)
|
||||
..addToken('rightParenthesis', rightParenthesis)
|
||||
..addNode('body', body);
|
||||
|
||||
|
|
|
@ -169,8 +169,8 @@ class ToSourceVisitor implements AstVisitor<void> {
|
|||
sink.write(' ');
|
||||
}
|
||||
sink.write('catch (');
|
||||
_visitNode(node.exceptionParameter2);
|
||||
_visitNode(node.stackTraceParameter2, prefix: ', ');
|
||||
_visitNode(node.exceptionParameter);
|
||||
_visitNode(node.stackTraceParameter, prefix: ', ');
|
||||
sink.write(') ');
|
||||
} else {
|
||||
sink.write(' ');
|
||||
|
|
|
@ -252,9 +252,9 @@ class AstComparator implements AstVisitor<bool> {
|
|||
isEqualNodes(node.exceptionType, other.exceptionType) &&
|
||||
isEqualTokens(node.catchKeyword, other.catchKeyword) &&
|
||||
isEqualTokens(node.leftParenthesis, other.leftParenthesis) &&
|
||||
isEqualNodes(node.exceptionParameter2, other.exceptionParameter2) &&
|
||||
isEqualNodes(node.exceptionParameter, other.exceptionParameter) &&
|
||||
isEqualTokens(node.comma, other.comma) &&
|
||||
isEqualNodes(node.stackTraceParameter2, other.stackTraceParameter2) &&
|
||||
isEqualNodes(node.stackTraceParameter, other.stackTraceParameter) &&
|
||||
isEqualTokens(node.rightParenthesis, other.rightParenthesis) &&
|
||||
isEqualNodes(node.body, other.body);
|
||||
}
|
||||
|
@ -2127,11 +2127,11 @@ class NodeReplacer extends ThrowingAstVisitor<bool> {
|
|||
if (identical(node.exceptionType, _oldNode)) {
|
||||
node.exceptionType = _newNode as TypeAnnotation;
|
||||
return true;
|
||||
} else if (identical(node.exceptionParameter2, _oldNode)) {
|
||||
node.exceptionParameter2 = _newNode as CatchClauseParameterImpl;
|
||||
} else if (identical(node.exceptionParameter, _oldNode)) {
|
||||
node.exceptionParameter = _newNode as CatchClauseParameterImpl;
|
||||
return true;
|
||||
} else if (identical(node.stackTraceParameter2, _oldNode)) {
|
||||
node.stackTraceParameter2 = _newNode as CatchClauseParameterImpl;
|
||||
} else if (identical(node.stackTraceParameter, _oldNode)) {
|
||||
node.stackTraceParameter = _newNode as CatchClauseParameterImpl;
|
||||
return true;
|
||||
} else if (identical(node.body, _oldNode)) {
|
||||
node.body = _newNode as Block;
|
||||
|
@ -3512,8 +3512,8 @@ class ScopedNameFinder extends GeneralizingAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitCatchClause(CatchClause node) {
|
||||
_addToScope(node.exceptionParameter2?.name);
|
||||
_addToScope(node.stackTraceParameter2?.name);
|
||||
_addToScope(node.exceptionParameter?.name);
|
||||
_addToScope(node.stackTraceParameter?.name);
|
||||
super.visitCatchClause(node);
|
||||
}
|
||||
|
||||
|
|
|
@ -501,8 +501,8 @@ class _AssignedVariablesVisitor extends RecursiveAstVisitor<void> {
|
|||
@override
|
||||
void visitCatchClause(CatchClause node) {
|
||||
for (var identifier in [
|
||||
node.exceptionParameter2,
|
||||
node.stackTraceParameter2,
|
||||
node.exceptionParameter,
|
||||
node.stackTraceParameter,
|
||||
]) {
|
||||
if (identifier != null) {
|
||||
assignedVariables.declare(identifier.declaredElement!);
|
||||
|
|
|
@ -221,7 +221,7 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
|
|||
exceptionTypeNode?.accept(this);
|
||||
|
||||
_withNameScope(() {
|
||||
var exceptionNode = node.exceptionParameter2;
|
||||
var exceptionNode = node.exceptionParameter;
|
||||
if (exceptionNode != null) {
|
||||
var element = LocalVariableElementImpl(
|
||||
exceptionNode.name.lexeme,
|
||||
|
@ -248,7 +248,7 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
|
|||
);
|
||||
}
|
||||
|
||||
var stackTraceNode = node.stackTraceParameter2;
|
||||
var stackTraceNode = node.stackTraceParameter;
|
||||
if (stackTraceNode != null) {
|
||||
var element = LocalVariableElementImpl(
|
||||
stackTraceNode.name.lexeme,
|
||||
|
|
|
@ -28,8 +28,8 @@ class DuplicateDefinitionVerifier {
|
|||
|
||||
/// Check that the exception and stack trace parameters have different names.
|
||||
void checkCatchClause(CatchClause node) {
|
||||
var exceptionParameter = node.exceptionParameter2;
|
||||
var stackTraceParameter = node.stackTraceParameter2;
|
||||
var exceptionParameter = node.exceptionParameter;
|
||||
var stackTraceParameter = node.stackTraceParameter;
|
||||
if (exceptionParameter != null && stackTraceParameter != null) {
|
||||
String exceptionName = exceptionParameter.name.lexeme;
|
||||
if (exceptionName == stackTraceParameter.name.lexeme) {
|
||||
|
|
|
@ -52,8 +52,8 @@ class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitCatchClause(CatchClause node) {
|
||||
var exceptionParameter = node.exceptionParameter2;
|
||||
var stackTraceParameter = node.stackTraceParameter2;
|
||||
var exceptionParameter = node.exceptionParameter;
|
||||
var stackTraceParameter = node.stackTraceParameter;
|
||||
if (exceptionParameter != null) {
|
||||
var element = exceptionParameter.declaredElement;
|
||||
usedElements.addCatchException(element);
|
||||
|
|
|
@ -2766,8 +2766,8 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
var catchClause = catchClauses[i];
|
||||
nullSafetyDeadCodeVerifier.verifyCatchClause(catchClause);
|
||||
flow.tryCatchStatement_catchBegin(
|
||||
catchClause.exceptionParameter2?.declaredElement,
|
||||
catchClause.stackTraceParameter2?.declaredElement,
|
||||
catchClause.exceptionParameter?.declaredElement,
|
||||
catchClause.stackTraceParameter?.declaredElement,
|
||||
);
|
||||
catchClause.accept(this);
|
||||
flow.tryCatchStatement_catchEnd();
|
||||
|
@ -3326,13 +3326,13 @@ class ScopeResolverVisitor extends UnifyingAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitCatchClause(CatchClause node) {
|
||||
var exception = node.exceptionParameter2;
|
||||
var exception = node.exceptionParameter;
|
||||
if (exception != null) {
|
||||
Scope outerScope = nameScope;
|
||||
try {
|
||||
nameScope = LocalScope(nameScope);
|
||||
_define(exception.declaredElement!);
|
||||
var stackTrace = node.stackTraceParameter2;
|
||||
var stackTrace = node.stackTraceParameter;
|
||||
if (stackTrace != null) {
|
||||
_define(stackTrace.declaredElement!);
|
||||
}
|
||||
|
|
|
@ -134,9 +134,9 @@ class AstTextPrinter extends ThrowingAstVisitor<void> {
|
|||
node.exceptionType?.accept(this);
|
||||
_token(node.catchKeyword);
|
||||
_token(node.leftParenthesis);
|
||||
node.exceptionParameter2?.accept(this);
|
||||
node.exceptionParameter?.accept(this);
|
||||
_token(node.comma);
|
||||
node.stackTraceParameter2?.accept(this);
|
||||
node.stackTraceParameter?.accept(this);
|
||||
_token(node.rightParenthesis);
|
||||
node.body.accept(this);
|
||||
}
|
||||
|
|
|
@ -1407,9 +1407,9 @@ main() {
|
|||
expect(clause.onKeyword, isNull);
|
||||
expect(clause.exceptionType, isNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2, isNotNull);
|
||||
expect(clause.exceptionParameter, isNotNull);
|
||||
expect(clause.comma, isNull);
|
||||
expect(clause.stackTraceParameter2, isNull);
|
||||
expect(clause.stackTraceParameter, isNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNull);
|
||||
expect(statement.finallyBlock, isNull);
|
||||
|
@ -1430,9 +1430,9 @@ main() {
|
|||
expect(clause.onKeyword, isNull);
|
||||
expect(clause.exceptionType, isNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2!.name.lexeme, 'int');
|
||||
expect(clause.exceptionParameter!.name.lexeme, 'int');
|
||||
expect(clause.comma, isNotNull);
|
||||
expect(clause.stackTraceParameter2!.name.lexeme, 'e');
|
||||
expect(clause.stackTraceParameter!.name.lexeme, 'e');
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNull);
|
||||
expect(statement.finallyBlock, isNull);
|
||||
|
@ -1449,9 +1449,9 @@ main() {
|
|||
expect(clause.onKeyword, isNull);
|
||||
expect(clause.exceptionType, isNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2, isNotNull);
|
||||
expect(clause.exceptionParameter, isNotNull);
|
||||
expect(clause.comma, isNull);
|
||||
expect(clause.stackTraceParameter2, isNull);
|
||||
expect(clause.stackTraceParameter, isNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNull);
|
||||
expect(statement.finallyBlock, isNull);
|
||||
|
@ -1468,9 +1468,9 @@ main() {
|
|||
expect(clause.onKeyword, isNull);
|
||||
expect(clause.exceptionType, isNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2, isNotNull);
|
||||
expect(clause.exceptionParameter, isNotNull);
|
||||
expect(clause.comma, isNull);
|
||||
expect(clause.stackTraceParameter2, isNull);
|
||||
expect(clause.stackTraceParameter, isNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNull);
|
||||
expect(statement.finallyBlock, isNull);
|
||||
|
@ -1487,9 +1487,9 @@ main() {
|
|||
expect(clause.onKeyword, isNull);
|
||||
expect(clause.exceptionType, isNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2, isNotNull);
|
||||
expect(clause.exceptionParameter, isNotNull);
|
||||
expect(clause.comma, isNotNull);
|
||||
expect(clause.stackTraceParameter2, isNotNull);
|
||||
expect(clause.stackTraceParameter, isNotNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNull);
|
||||
expect(statement.finallyBlock, isNull);
|
||||
|
@ -1507,9 +1507,9 @@ main() {
|
|||
expect(clause.onKeyword, isNull);
|
||||
expect(clause.exceptionType, isNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2, isNotNull);
|
||||
expect(clause.exceptionParameter, isNotNull);
|
||||
expect(clause.comma, isNotNull);
|
||||
expect(clause.stackTraceParameter2, isNotNull);
|
||||
expect(clause.stackTraceParameter, isNotNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNotNull);
|
||||
expect(statement.finallyBlock, isNotNull);
|
||||
|
@ -1548,9 +1548,9 @@ main() {
|
|||
expect(clause.onKeyword, isNotNull);
|
||||
expect(clause.exceptionType, isNotNull);
|
||||
expect(clause.catchKeyword, isNull);
|
||||
expect(clause.exceptionParameter2, isNull);
|
||||
expect(clause.exceptionParameter, isNull);
|
||||
expect(clause.comma, isNull);
|
||||
expect(clause.stackTraceParameter2, isNull);
|
||||
expect(clause.stackTraceParameter, isNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNull);
|
||||
expect(statement.finallyBlock, isNull);
|
||||
|
@ -1568,9 +1568,9 @@ main() {
|
|||
expect(clause.onKeyword, isNotNull);
|
||||
expect(clause.exceptionType, isNotNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2, isNotNull);
|
||||
expect(clause.exceptionParameter, isNotNull);
|
||||
expect(clause.comma, isNotNull);
|
||||
expect(clause.stackTraceParameter2, isNotNull);
|
||||
expect(clause.stackTraceParameter, isNotNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNull);
|
||||
expect(statement.finallyBlock, isNull);
|
||||
|
@ -1588,9 +1588,9 @@ main() {
|
|||
expect(clause.onKeyword, isNotNull);
|
||||
expect(clause.exceptionType, isNotNull);
|
||||
expect(clause.catchKeyword, isNotNull);
|
||||
expect(clause.exceptionParameter2, isNotNull);
|
||||
expect(clause.exceptionParameter, isNotNull);
|
||||
expect(clause.comma, isNotNull);
|
||||
expect(clause.stackTraceParameter2, isNotNull);
|
||||
expect(clause.stackTraceParameter, isNotNull);
|
||||
expect(clause.body, isNotNull);
|
||||
expect(statement.finallyKeyword, isNotNull);
|
||||
expect(statement.finallyBlock, isNotNull);
|
||||
|
|
|
@ -386,8 +386,8 @@ void f() {
|
|||
source: findNode.catchClause('(e2,'),
|
||||
childAccessors: [
|
||||
(node) => node.exceptionType!,
|
||||
(node) => node.exceptionParameter2!,
|
||||
(node) => node.stackTraceParameter2!,
|
||||
(node) => node.exceptionParameter!,
|
||||
(node) => node.stackTraceParameter!,
|
||||
(node) => node.body,
|
||||
],
|
||||
);
|
||||
|
|
|
@ -7533,11 +7533,11 @@ void main() {
|
|||
CatchClause catchClause = statement.catchClauses[0];
|
||||
expect(catchClause.exceptionType, isNull);
|
||||
|
||||
var exceptionNode = catchClause.exceptionParameter2!;
|
||||
var exceptionNode = catchClause.exceptionParameter!;
|
||||
var exceptionElement = exceptionNode.declaredElement!;
|
||||
expect(exceptionElement.type, typeProvider.objectType);
|
||||
|
||||
var stackNode = catchClause.stackTraceParameter2!;
|
||||
var stackNode = catchClause.stackTraceParameter!;
|
||||
var stackElement = stackNode.declaredElement!;
|
||||
expect(stackElement.type, typeProvider.stackTraceType);
|
||||
|
||||
|
@ -7562,11 +7562,11 @@ void main() {
|
|||
_assertNamedTypeSimple(
|
||||
catchClause.exceptionType as NamedType, typeProvider.intType);
|
||||
|
||||
var exceptionNode = catchClause.exceptionParameter2!;
|
||||
var exceptionNode = catchClause.exceptionParameter!;
|
||||
var exceptionElement = exceptionNode.declaredElement!;
|
||||
expect(exceptionElement.type, typeProvider.intType);
|
||||
|
||||
var stackNode = catchClause.stackTraceParameter2!;
|
||||
var stackNode = catchClause.stackTraceParameter!;
|
||||
var stackElement = stackNode.declaredElement!;
|
||||
expect(stackElement.type, typeProvider.stackTraceType);
|
||||
|
||||
|
@ -7589,9 +7589,9 @@ void main() {
|
|||
var statement = statements[2] as TryStatement;
|
||||
CatchClause catchClause = statement.catchClauses[0];
|
||||
expect(catchClause.exceptionType, isNull);
|
||||
expect(catchClause.stackTraceParameter2, isNull);
|
||||
expect(catchClause.stackTraceParameter, isNull);
|
||||
|
||||
var exceptionNode = catchClause.exceptionParameter2!;
|
||||
var exceptionNode = catchClause.exceptionParameter!;
|
||||
var exceptionElement = exceptionNode.declaredElement!;
|
||||
expect(exceptionElement.type, typeProvider.objectType);
|
||||
}
|
||||
|
@ -7601,9 +7601,9 @@ void main() {
|
|||
var statement = statements[3] as TryStatement;
|
||||
CatchClause catchClause = statement.catchClauses[0];
|
||||
_assertNamedTypeSimple(catchClause.exceptionType!, typeProvider.intType);
|
||||
expect(catchClause.stackTraceParameter2, isNull);
|
||||
expect(catchClause.stackTraceParameter, isNull);
|
||||
|
||||
var exceptionNode = catchClause.exceptionParameter2!;
|
||||
var exceptionNode = catchClause.exceptionParameter!;
|
||||
var exceptionElement = exceptionNode.declaredElement!;
|
||||
expect(exceptionElement.type, typeProvider.intType);
|
||||
}
|
||||
|
@ -7614,8 +7614,8 @@ void main() {
|
|||
CatchClause catchClause = statement.catchClauses[0];
|
||||
_assertNamedTypeSimple(
|
||||
catchClause.exceptionType as NamedType, typeProvider.intType);
|
||||
expect(catchClause.exceptionParameter2, isNull);
|
||||
expect(catchClause.stackTraceParameter2, isNull);
|
||||
expect(catchClause.exceptionParameter, isNull);
|
||||
expect(catchClause.stackTraceParameter, isNull);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ main() {
|
|||
assertType(st.type, 'StackTrace');
|
||||
|
||||
var node = findNode.catchClause('catch');
|
||||
expect(node.exceptionParameter2!.declaredElement, e);
|
||||
expect(node.stackTraceParameter2!.declaredElement, st);
|
||||
expect(node.exceptionParameter!.declaredElement, e);
|
||||
expect(node.stackTraceParameter!.declaredElement, st);
|
||||
}
|
||||
|
||||
test_catch_withType() async {
|
||||
|
@ -58,7 +58,7 @@ main() {
|
|||
assertType(st.type, 'StackTrace');
|
||||
|
||||
var node = findNode.catchClause('catch');
|
||||
expect(node.exceptionParameter2!.declaredElement, e);
|
||||
expect(node.stackTraceParameter2!.declaredElement, st);
|
||||
expect(node.exceptionParameter!.declaredElement, e);
|
||||
expect(node.stackTraceParameter!.declaredElement, st);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ abstract class LocalDeclarationVisitor extends GeneralizingAstVisitor {
|
|||
|
||||
@override
|
||||
void visitCatchClause(CatchClause node) {
|
||||
var exceptionParameter = node.exceptionParameter2;
|
||||
var exceptionParameter = node.exceptionParameter;
|
||||
if (exceptionParameter != null) {
|
||||
declaredParam(
|
||||
exceptionParameter.name,
|
||||
|
@ -87,7 +87,7 @@ abstract class LocalDeclarationVisitor extends GeneralizingAstVisitor {
|
|||
);
|
||||
}
|
||||
|
||||
var stackTraceParameter = node.stackTraceParameter2;
|
||||
var stackTraceParameter = node.stackTraceParameter;
|
||||
if (stackTraceParameter != null) {
|
||||
declaredParam(
|
||||
stackTraceParameter.name,
|
||||
|
|
|
@ -648,8 +648,8 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
|
|||
@override
|
||||
DecoratedType? visitCatchClause(CatchClause node) {
|
||||
_flowAnalysis!.tryCatchStatement_catchBegin(
|
||||
node.exceptionParameter2?.declaredElement,
|
||||
node.stackTraceParameter2?.declaredElement);
|
||||
node.exceptionParameter?.declaredElement,
|
||||
node.stackTraceParameter?.declaredElement);
|
||||
_dispatch(node.exceptionType);
|
||||
// The catch clause may not execute, so create a new scope for
|
||||
// post-dominators.
|
||||
|
|
|
@ -90,37 +90,37 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
|
|||
|
||||
@override
|
||||
DecoratedType? visitCatchClause(CatchClause node) {
|
||||
var exceptionElement = node.exceptionParameter2?.declaredElement;
|
||||
var exceptionElement = node.exceptionParameter?.declaredElement;
|
||||
var target = exceptionElement == null
|
||||
? NullabilityNodeTarget.text('exception type')
|
||||
: NullabilityNodeTarget.element(exceptionElement);
|
||||
DecoratedType? exceptionType = _pushNullabilityNodeTarget(
|
||||
target, () => node.exceptionType?.accept(this));
|
||||
if (node.exceptionParameter2 != null) {
|
||||
if (node.exceptionParameter != null) {
|
||||
// If there is no `on Type` part of the catch clause, the type is dynamic.
|
||||
if (exceptionType == null) {
|
||||
exceptionType = DecoratedType.forImplicitType(_typeProvider,
|
||||
_typeProvider.dynamicType, _graph, target.withCodeRef(node));
|
||||
instrumentation?.implicitType(
|
||||
source, node.exceptionParameter2, exceptionType);
|
||||
source, node.exceptionParameter, exceptionType);
|
||||
}
|
||||
_variables!.recordDecoratedElementType(
|
||||
node.exceptionParameter2?.declaredElement, exceptionType);
|
||||
node.exceptionParameter?.declaredElement, exceptionType);
|
||||
}
|
||||
if (node.stackTraceParameter2 != null) {
|
||||
if (node.stackTraceParameter != null) {
|
||||
// The type of stack traces is always StackTrace (non-nullable).
|
||||
var target = NullabilityNodeTarget.text('stack trace').withCodeRef(node);
|
||||
var nullabilityNode = NullabilityNode.forInferredType(target);
|
||||
_graph.makeNonNullableUnion(nullabilityNode,
|
||||
StackTraceTypeOrigin(source, node.stackTraceParameter2));
|
||||
StackTraceTypeOrigin(source, node.stackTraceParameter));
|
||||
var stackTraceType =
|
||||
DecoratedType(_typeProvider.stackTraceType, nullabilityNode);
|
||||
_variables!.recordDecoratedElementType(
|
||||
node.stackTraceParameter2?.declaredElement, stackTraceType);
|
||||
node.stackTraceParameter?.declaredElement, stackTraceType);
|
||||
instrumentation?.implicitType(
|
||||
source, node.stackTraceParameter2, stackTraceType);
|
||||
source, node.stackTraceParameter, stackTraceType);
|
||||
}
|
||||
node.stackTraceParameter2?.accept(this);
|
||||
node.stackTraceParameter?.accept(this);
|
||||
node.body.accept(this);
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue