[dart2wasm] Fix some uses of void.

Change-Id: Ia05014c2ce155834b0b3a327a40e500cd0c2941d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250540
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
This commit is contained in:
Joshua Litt 2022-07-25 23:05:16 +00:00 committed by Commit Bot
parent 4448741898
commit 3e22f16204
2 changed files with 15 additions and 9 deletions

View file

@ -291,7 +291,9 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
b.struct_set(info.struct, translator.typeParameterIndex[typeParam]!);
}
for (Field field in cls.fields) {
if (field.isInstanceMember && field.initializer != null) {
if (field.isInstanceMember &&
field.initializer != null &&
field.type is! VoidType) {
int fieldIndex = translator.fieldIndex[field]!;
b.local_get(thisLocal!);
wrap(
@ -1420,6 +1422,10 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
@override
w.ValueType visitVariableGet(VariableGet node, w.ValueType expectedType) {
// Return `void` for a void [VariableGet].
if (node.variable.type is VoidType) {
return voidMarker;
}
w.Local? local = locals[node.variable];
Capture? capture = closures.captures[node.variable];
if (capture != null) {
@ -1442,6 +1448,10 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
@override
w.ValueType visitVariableSet(VariableSet node, w.ValueType expectedType) {
// Return `void` for a void [VariableSet].
if (node.variable.type is VoidType) {
return wrap(node.value, voidMarker);
}
w.Local? local = locals[node.variable];
Capture? capture = closures.captures[node.variable];
bool preserved = expectedType != voidMarker;

View file

@ -538,18 +538,14 @@ class Translator {
return typeForInfo(
classInfo[type.classNode]!, type.isPotentiallyNullable);
}
if (type is DynamicType) {
if (type is DynamicType || type is VoidType) {
return topInfo.nullableType;
}
if (type is NullType) {
// TODO(joshualitt): When we add support to `wasm_builder` for bottom heap
// types, we should return bottom heap type here.
if (type is NullType || type is NeverType) {
return topInfo.nullableType;
}
if (type is NeverType) {
return topInfo.nullableType;
}
if (type is VoidType) {
return voidMarker;
}
if (type is TypeParameterType) {
return translateStorageType(type.isPotentiallyNullable
? type.bound.withDeclaredNullability(type.nullability)