-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-dart2js
Description
The following code incorrectly prints true instead of false.
class Foo {
int f() => 42;
}
class Bar extends Foo {
void test() {
var f = super.f;
print(f is int);
}
}
void main() {
Bar().test();
}We build an HInvokeSuper node for the super.f access here:
sdk/pkg/compiler/lib/src/ssa/builder_kernel.dart
Lines 5292 to 5299 in ce7fcff
| _buildInvokeSuper( | |
| _elementMap.getSelector(node), | |
| _elementMap.getClass(_containingClass(node)), | |
| member, | |
| const <HInstruction>[], | |
| const <DartType>[], | |
| sourceInformation); | |
| } |
The problem is that this is indistinguishable from the node we would have built for the method invocation
super.f():sdk/pkg/compiler/lib/src/ssa/builder_kernel.dart
Lines 5331 to 5338 in ce7fcff
| _buildInvokeSuper( | |
| _elementMap.getSelector(node), | |
| _elementMap.getClass(_containingClass(node)), | |
| member, | |
| arguments, | |
| typeArguments, | |
| sourceInformation); | |
| } |
When we build the node, we attempt to determine the type by inspecting the member:
sdk/pkg/compiler/lib/src/ssa/builder_kernel.dart
Lines 5251 to 5255 in ce7fcff
| if (target is FunctionEntity) { | |
| typeMask = _typeInferenceMap.getReturnTypeOf(target); | |
| } else { | |
| typeMask = _abstractValueDomain.dynamicType; | |
| } |
Of course, in both super.f and super.f(), the member is the same FunctionEntity, but only in the latter case does it make sense to use the return type.
Metadata
Metadata
Assignees
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-dart2js