mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:01:30 +00:00
Add type inference for invalid constructor initializers.
R=scheglov@google.com Review-Url: https://codereview.chromium.org/2998573002 .
This commit is contained in:
parent
5011b024df
commit
107335c1d0
3 changed files with 21 additions and 1 deletions
|
@ -3137,7 +3137,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
|||
Initializer buildInvalidInitializer(Expression expression,
|
||||
[int charOffset = -1]) {
|
||||
needsImplicitSuperInitializer = false;
|
||||
return new LocalInitializer(new VariableDeclaration.forValue(expression))
|
||||
return new KernelInvalidInitializer(
|
||||
new VariableDeclaration.forValue(expression))
|
||||
..fileOffset = charOffset;
|
||||
}
|
||||
|
||||
|
|
|
@ -1019,6 +1019,19 @@ class KernelIntLiteral extends IntLiteral implements KernelExpression {
|
|||
}
|
||||
}
|
||||
|
||||
/// Concrete shadow object representing an invalid initializer in kernel form.
|
||||
class KernelInvalidInitializer extends LocalInitializer
|
||||
implements KernelInitializer {
|
||||
KernelInvalidInitializer(VariableDeclaration variable) : super(variable);
|
||||
|
||||
@override
|
||||
void _inferInitializer(KernelTypeInferrer inferrer) {
|
||||
inferrer.listener.invalidInitializerEnter(this);
|
||||
inferrer.inferExpression(variable.initializer, null, false);
|
||||
inferrer.listener.invalidInitializerExit(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// Concrete shadow object representing a non-inverted "is" test in kernel form.
|
||||
class KernelIsExpression extends IsExpression implements KernelExpression {
|
||||
KernelIsExpression(Expression operand, DartType type) : super(operand, type);
|
||||
|
|
|
@ -232,6 +232,12 @@ class TypeInferenceListener
|
|||
void intLiteralExit(IntLiteral expression, DartType inferredType) =>
|
||||
genericExpressionExit("intLiteral", expression, inferredType);
|
||||
|
||||
void invalidInitializerEnter(LocalInitializer initializer) =>
|
||||
genericInitializerEnter("invalidInitializer", initializer);
|
||||
|
||||
void invalidInitializerExit(LocalInitializer initializer) =>
|
||||
genericInitializerExit("invalidInitializer", initializer);
|
||||
|
||||
bool isExpressionEnter(IsExpression expression, DartType typeContext) =>
|
||||
genericExpressionEnter("isExpression", expression, typeContext);
|
||||
|
||||
|
|
Loading…
Reference in a new issue