[vm/nnbd] Fix nullability of types in inferred types attribute

VM doesn't expect legacy nullability for Null type, so nullability
should be adjusted when writing AOT-specific inferred types attribute in
bytecode.

Change-Id: I58b09c9931f3cce6e70f661f1ba3e7e015e7f739
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127985
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2019-12-10 22:03:16 +00:00 committed by commit-bot@chromium.org
parent e03aeada28
commit b57e10ad28

View file

@ -1805,8 +1805,11 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
// VM uses more specific function type and doesn't expect to
// see inferred _Closure class.
if (concreteClass != null && concreteClass != closureClass) {
inferredTypesAttribute
.add(TypeLiteralConstant(coreTypes.legacyRawType(concreteClass)));
inferredTypesAttribute.add(TypeLiteralConstant(coreTypes.rawType(
concreteClass,
(concreteClass == coreTypes.nullClass)
? Nullability.nullable
: staticTypeContext.nonNullable)));
} else {
inferredTypesAttribute.add(NullConstant());
}