-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P1A high priority bug; for example, a single project is unusable or has many test failuresA high priority bug; for example, a single project is unusable or has many test failureslegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone
Description
CFE crashes when it compiles the following code:
class Foo<T> {
final Future<dynamic> Function() quux;
T t;
Foo(this.quux, this.t);
Future<T> call() => quux().then<T>((_) => t);
}
class Bar {
Foo<Baz> qux;
Future<void> quuz() =>
qux().then((baz) => corge(baz)).then((grault) => garply(grault));
Grault corge(Baz baz) => null;
void garply(Grault grault) {}
}
class Baz {}
class Grault {}The top of the stack trace is the following:
Unhandled exception:
Crash when compiling file:///tmp/asdf.dart,
at character offset 191:
dynamic is not a subtype of dart.async::Future in this.{#lib1::Bar::qux}()
#0 TypeEnvironment.typeError (package:kernel/type_environment.dart:103:7)
#1 Expression.getStaticTypeAsInstanceOf (package:kernel/ast.dart:2186:11)
#2 MethodInvocation.getStaticType (package:kernel/ast.dart:2795:35)
#3 KernelLibraryBuilder.checkBoundsInMethodInvocation (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1831:36)
#4 InferenceVistor.visitMethodInvocationJudgment (file:///usr/local/google/home/dmitryas/dart/sdk/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart:887:23)
#5 MethodInvocationJudgment.acceptInference (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:1129:20)
#6 ShadowTypeInferrer.inferExpression (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:1631:18)
#7 InferenceVistor.visitReturnJudgment (file:///usr/local/google/home/dmitryas/dart/sdk/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart:1024:16)
#8 ReturnJudgment.acceptInference (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:1302:20)
#9 ShadowTypeInferrer.inferStatement (package:front_end/src/fasta/kernel/kernel_shadow_ast.dart:1679:24)
#10 TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:1223:5)
#11 BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:724:19)
#12 DietListener.listenerFinishFunction (package:front_end/src/fasta/source/diet_listener.dart:795:14)
#13 DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:829:7)
#14 DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:578:5)
#15 Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3030:14)
#16 Parser.parseClassOrMixinMemberImpl (package:front_end/src/fasta/parser/parser.dart:2895:15)
#17 Parser.parseClassOrMixinBody (package:front_end/src/fasta/parser/parser.dart:2700:15)
#18 Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1710:13)
#19 Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1670:14)
#20 Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:565:14)
#21 Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:457:14)
#22 Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:336:15)
#23 SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:253:14)
...
Metadata
Metadata
Assignees
Labels
P1A high priority bug; for example, a single project is unusable or has many test failuresA high priority bug; for example, a single project is unusable or has many test failureslegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Type
Projects
Relationships
Development
Select code repository
Activity
[fasta] Add a test case for issue #34899
kmillikin commentedon Oct 23, 2018
One underlying problem with the existing implementation in terms of
getStaticTypeis issue #34497.Basically, for an invocation of a getter whose static type is a callable object (
this.qux()in the test case) we generateMethodInvocation(This, 'qux', [])and we should generateMethodInvocation(PropertyGet(This, 'qux'), 'call', []). The former is not what we intend and the Kernel type checker says that it has typedynamic.(This is inconsistent with what we do for static getters whose static type is a callable object, where we produce
MethodInvocation(StaticGet(target), 'call', []); and for invoking a local variable whose static type is a callable object, where we produceMethodInvocation(VariableGet(definition), 'call', []).)I've started work on #34497.
kmillikin commentedon Oct 23, 2018
Work in progress on a fix is in https://dart-review.googlesource.com/c/sdk/+/81266