diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index aa89d12cfa8..48bd0e05368 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -1477,6 +1477,7 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { @override void handleFunctionType(Token functionToken, Token endToken) { + debugEvent("FunctionType"); FormalParameters formals = pop(); ignore(Unhandled.TypeVariables); DartType returnType = pop(); @@ -1590,9 +1591,9 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { } } variable ??= astFactory.variableDeclaration( - name.name, name.token, functionNestingLevel, + name?.name, name?.token, functionNestingLevel, type: type, - initializer: name.initializer, + initializer: name?.initializer, isFinal: isFinal, isConst: isConst); push(variable); @@ -1657,7 +1658,8 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { optional, beginToken.charOffset); push(formals); - if (inCatchClause || functionNestingLevel != 0) { + if ((inCatchClause || functionNestingLevel != 0) && + kind != MemberKind.GeneralizedFunctionType) { enterLocalScope(formals.computeFormalParameterScope( scope, member ?? classBuilder ?? library)); } diff --git a/pkg/front_end/testcases/function_type_is_check.dart b/pkg/front_end/testcases/function_type_is_check.dart new file mode 100644 index 00000000000..706ac9e3512 --- /dev/null +++ b/pkg/front_end/testcases/function_type_is_check.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart" show Expect; + +test(f) { + if (f is void Function(Object, StackTrace)) return 1; + if (f is void Function(Object)) return 10; + if (f is void Function()) return 100; +} + +main() { + Expect.equals( + 111, + test(() => null) + + test((Object o) => null) + + test((Object o, StackTrace t) => null)); +} diff --git a/pkg/front_end/testcases/function_type_is_check.dart.direct.expect b/pkg/front_end/testcases/function_type_is_check.dart.direct.expect new file mode 100644 index 00000000000..47e328147ee --- /dev/null +++ b/pkg/front_end/testcases/function_type_is_check.dart.direct.expect @@ -0,0 +1,16 @@ +library; +import self as self; +import "dart:core" as core; +import "package:expect/expect.dart" as exp; + +static method test(dynamic f) → dynamic { + if(f is (core::Object, core::StackTrace) → void) + return 1; + if(f is (core::Object) → void) + return 10; + if(f is () → void) + return 100; +} +static method main() → dynamic { + exp::Expect::equals(111, self::test(() → dynamic => null).+(self::test((core::Object o) → dynamic => null)).+(self::test((core::Object o, core::StackTrace t) → dynamic => null))); +} diff --git a/pkg/front_end/testcases/function_type_is_check.dart.outline.expect b/pkg/front_end/testcases/function_type_is_check.dart.outline.expect new file mode 100644 index 00000000000..b9650b82be3 --- /dev/null +++ b/pkg/front_end/testcases/function_type_is_check.dart.outline.expect @@ -0,0 +1,7 @@ +library; +import self as self; + +static method test(dynamic f) → dynamic + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/function_type_is_check.dart.strong.expect b/pkg/front_end/testcases/function_type_is_check.dart.strong.expect new file mode 100644 index 00000000000..47e328147ee --- /dev/null +++ b/pkg/front_end/testcases/function_type_is_check.dart.strong.expect @@ -0,0 +1,16 @@ +library; +import self as self; +import "dart:core" as core; +import "package:expect/expect.dart" as exp; + +static method test(dynamic f) → dynamic { + if(f is (core::Object, core::StackTrace) → void) + return 1; + if(f is (core::Object) → void) + return 10; + if(f is () → void) + return 100; +} +static method main() → dynamic { + exp::Expect::equals(111, self::test(() → dynamic => null).+(self::test((core::Object o) → dynamic => null)).+(self::test((core::Object o, core::StackTrace t) → dynamic => null))); +} diff --git a/pkg/front_end/tool/fasta b/pkg/front_end/tool/fasta index 45a5f3d1b0b..4d269f33f9f 100755 --- a/pkg/front_end/tool/fasta +++ b/pkg/front_end/tool/fasta @@ -20,6 +20,8 @@ function stop { exit 1 } +DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64} + case "${1//_/-}" in abcompile) SCRIPT="${TOOL_DIR}/abcompile.dart";; analyzer-compile) SCRIPT="${TOOL_DIR}/analyzer_compile.dart";; @@ -49,7 +51,11 @@ case "${1//_/-}" in ;; kernel-service) shift + PATCHED_SDK_DIR=$( + ls -d {xcodebuild,out}/${DART_CONFIGURATION}/patched_sdk 2>/dev/null \ + | head -1) exec "${DART_VM}" -c -DDFE_VERBOSE=true \ + --platform=${PATCHED_SDK_DIR}/platform.dill \ --dfe="${REPO_DIR}/utils/kernel-service/kernel-service.dart" "$@" ;; testing) @@ -64,4 +70,4 @@ esac shift -DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64} exec "${DART_VM}" -c "${SCRIPT}" "$@" +exec "${DART_VM}" -c "${SCRIPT}" "$@"