Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dart2wasm] Generics unexpected runtimeType when extends to nullable #55741

Closed
huanghui1998hhh opened this issue May 16, 2024 · 6 comments
Closed
Labels
area-dart2wasm Issues for the dart2wasm compiler. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@huanghui1998hhh
Copy link

void main() {
  print(AlwaysNullableData('').runtimeType);
}

abstract class BaseData<T> {
  BaseData(this.data);

  T data;
}

class AlwaysNullableData<T> extends BaseData<T?> {
  AlwaysNullableData(super.data);
}

This code will print AlwaysNullableData<String> on other platform, but on dart2wasm it print AlwaysNullableData<String?>

@lrhn lrhn added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-dart2wasm Issues for the dart2wasm compiler. labels May 16, 2024
@lrhn
Copy link
Member

lrhn commented May 16, 2024

That is a bug. The inferred type argument of AlwaysNullableData('') is <String>, so that's what T should be bound to, and then the type argument to BaseData is T?.

@mkustermann
Copy link
Member

That is a bug. The inferred type argument of AlwaysNullableData('') is , so that's what T should be bound to, and then the type argument to BaseData is T?.

@lrhn to clarify: It should print AlwaysNullableData<String?>? Then it would be a bug in other platforms, not in wasm, right?

@eernstg
Copy link
Member

eernstg commented May 16, 2024

It should print AlwaysNullableData<String>, but is BaseData<String?> should be true.

@mkustermann
Copy link
Member

Don't know what I was thinking, yes of course the RTT is from the bottom class and it has to print the non-nullable one.

I think the type parameter sharing we do doesn't consider nullability, we'll fix it.

@lrhn
Copy link
Member

lrhn commented May 16, 2024

doesn't consider nullability

That sound ... plausible.

@mkustermann
Copy link
Member

cl/366940 should fix it.

copybara-service bot pushed a commit that referenced this issue Jun 3, 2024
…allows

Bug: #55741

Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/366940
Cherry-pick-request: #55895
Change-Id: I69b31dfff0eddd437becae79a5ae49683906088d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369241
Reviewed-by: Ömer Ağacan <[email protected]>
Commit-Queue: Martin Kustermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart2wasm Issues for the dart2wasm compiler. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants