[kernel] Non-nullable enclosingClass for Constructor members
Change-Id: I2a31e4272f9119c229e1eea8a75114f5c2bf82b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186281
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index f631b4d..af89d14 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -2108,6 +2108,9 @@
this.transformerFlags = transformerFlags;
}
+ @override
+ Class get enclosingClass => parent as Class;
+
static const int FlagConst = 1 << 0; // Must match serialized bit positions.
static const int FlagExternal = 1 << 1;
static const int FlagSynthetic = 1 << 2;
@@ -2286,6 +2289,9 @@
this.transformerFlags = transformerFlags;
}
+ @override
+ Class get enclosingClass => parent as Class;
+
static const int FlagConst = 1 << 0; // Must match serialized bit positions.
static const int FlagExternal = 1 << 1;
static const int FlagNonNullableByDefault = 1 << 2;
@@ -3365,7 +3371,7 @@
// transformations like erasure don't work.
List<TypeParameter> typeParametersCopy = new List<TypeParameter>.from(
parent is Constructor
- ? parent.enclosingClass!.typeParameters
+ ? parent.enclosingClass.typeParameters
: typeParameters);
return new FunctionType(
positionalParameters.map(_getTypeOfVariable).toList(growable: false),
@@ -3405,7 +3411,7 @@
// We need create a copy of the list of type parameters, otherwise
// transformations like erasure don't work.
List<TypeParameter> classTypeParametersCopy =
- List.from(parentConstructor.enclosingClass!.typeParameters);
+ List.from(parentConstructor.enclosingClass.typeParameters);
List<TypeParameter> typedefTypeParametersCopy =
List.from(typedef.typeParameters);
List<DartType> asTypeArguments =
@@ -6149,9 +6155,9 @@
DartType getStaticTypeInternal(StaticTypeContext context) {
return arguments.types.isEmpty
? context.typeEnvironment.coreTypes
- .rawType(target.enclosingClass!, context.nonNullable)
+ .rawType(target.enclosingClass, context.nonNullable)
: new InterfaceType(
- target.enclosingClass!, context.nonNullable, arguments.types);
+ target.enclosingClass, context.nonNullable, arguments.types);
}
@override
@@ -6187,7 +6193,7 @@
// TODO(dmitryas): Change the getter into a method that accepts a CoreTypes.
InterfaceType get constructedType {
- Class enclosingClass = target.enclosingClass!;
+ Class enclosingClass = target.enclosingClass;
// TODO(dmitryas): Get raw type from a CoreTypes object if arguments is
// empty.
return arguments.types.isEmpty
@@ -6209,7 +6215,7 @@
} else {
printer.write('new ');
}
- printer.writeClassName(target.enclosingClass!.reference);
+ printer.writeClassName(target.enclosingClass.reference);
printer.writeTypeArguments(arguments.types);
if (target.name!.text.isNotEmpty) {
printer.write('.');
diff --git a/pkg/kernel/lib/verifier.dart b/pkg/kernel/lib/verifier.dart
index 1ca7114..8cbf77b 100644
--- a/pkg/kernel/lib/verifier.dart
+++ b/pkg/kernel/lib/verifier.dart
@@ -645,7 +645,7 @@
"${node.runtimeType} with incompatible arguments for '${target}'.");
}
int expectedTypeParameters = target is Constructor
- ? target.enclosingClass!.typeParameters.length
+ ? target.enclosingClass.typeParameters.length
: target.function!.typeParameters.length;
if (node.arguments.types.length != expectedTypeParameters) {
problem(
@@ -658,7 +658,7 @@
@override
visitConstructorInvocation(ConstructorInvocation node) {
checkTargetedInvocation(node.target, node);
- if (node.target.enclosingClass!.isAbstract) {
+ if (node.target.enclosingClass.isAbstract) {
problem(node, "ConstructorInvocation of abstract class.");
}
if (node.isConst && !node.target.isConst) {