mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:29:48 +00:00
Fix the precedence of FunctionExpression
FunctionExpression should have a low precedence to ensure that it is properly parenthesized. Fixes https://github.com/dart-lang/sdk/issues/31380 Bug: Change-Id: I2ca2bb728973c5b374411dc07fdadc4dda8c707b Reviewed-on: https://dart-review.googlesource.com/21343 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Kevin Millikin <kmillikin@google.com>
This commit is contained in:
parent
851ff574a3
commit
02511ceeb4
|
@ -4,14 +4,14 @@ import "dart:core" as core;
|
|||
|
||||
class C extends core::Object {
|
||||
constructor expressionOnly() → void
|
||||
: final dynamic #t1 = () → dynamic
|
||||
: final dynamic #t1 = (() → dynamic
|
||||
assert(self::f<dynamic>());
|
||||
.call(), super core::Object::•()
|
||||
).call(), super core::Object::•()
|
||||
;
|
||||
constructor expressionAndMessage() → void
|
||||
: final dynamic #t2 = () → dynamic
|
||||
: final dynamic #t2 = (() → dynamic
|
||||
assert(self::f<dynamic>(), self::f<dynamic>());
|
||||
.call(), super core::Object::•()
|
||||
).call(), super core::Object::•()
|
||||
;
|
||||
}
|
||||
static method f<T extends core::Object>() → self::f::T
|
||||
|
|
|
@ -4,14 +4,14 @@ import "dart:core" as core;
|
|||
|
||||
class C extends core::Object {
|
||||
constructor expressionOnly() → void
|
||||
: final dynamic #t1 = () → dynamic
|
||||
: final dynamic #t1 = (() → dynamic
|
||||
assert(self::f<core::bool>());
|
||||
.call(), super core::Object::•()
|
||||
).call(), super core::Object::•()
|
||||
;
|
||||
constructor expressionAndMessage() → void
|
||||
: final dynamic #t2 = () → dynamic
|
||||
: final dynamic #t2 = (() → dynamic
|
||||
assert(self::f<core::bool>(), self::f<dynamic>());
|
||||
.call(), super core::Object::•()
|
||||
).call(), super core::Object::•()
|
||||
;
|
||||
}
|
||||
static method f<T extends core::Object>() → self::f::T
|
||||
|
|
|
@ -9,7 +9,7 @@ static method test() → dynamic {
|
|||
return null;
|
||||
};
|
||||
core::String y = f.call(42);
|
||||
f = (core::Object x) → core::String => "hello" as{TypeError} (core::Object) → core::Null;
|
||||
f = ((core::Object x) → core::String => "hello") as{TypeError} (core::Object) → core::Null;
|
||||
self::foo((core::Object x) → core::Null {
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -9,8 +9,8 @@ static method test() → void {
|
|||
<S extends core::Object>(core::int) → core::String v = f;
|
||||
v = <T extends core::Object>(core::int x) → core::String => null;
|
||||
v = <T extends core::Object>(core::int x) → core::String => "hello";
|
||||
v = <T extends core::Object>(core::String x) → core::String => "hello" as{TypeError} <S extends core::Object>(core::int) → core::String;
|
||||
v = <T extends core::Object>(core::int x) → core::int => 3 as{TypeError} <S extends core::Object>(core::int) → core::String;
|
||||
v = (<T extends core::Object>(core::String x) → core::String => "hello") as{TypeError} <S extends core::Object>(core::int) → core::String;
|
||||
v = (<T extends core::Object>(core::int x) → core::int => 3) as{TypeError} <S extends core::Object>(core::int) → core::String;
|
||||
v = <T extends core::Object>(core::int x) → core::String {
|
||||
return 3;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ static method test() → void {
|
|||
<S extends core::Object>(core::int) → core::String v = f;
|
||||
v = <T extends core::Object>(core::int x) → core::String => null;
|
||||
v = <T extends core::Object>(core::int x) → core::String => "hello";
|
||||
v = <T extends core::Object>(core::int x) → core::int => 3 as{TypeError} <S extends core::Object>(core::int) → core::String;
|
||||
v = (<T extends core::Object>(core::int x) → core::int => 3) as{TypeError} <S extends core::Object>(core::int) → core::String;
|
||||
v = <T extends core::Object>(core::int x) → core::String {
|
||||
return 3;
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ static method test() → void {
|
|||
<S extends core::Object>(core::int) → core::List<core::String> v = f;
|
||||
v = <T extends core::Object>(core::int x) → core::List<core::String> => null;
|
||||
v = <T extends core::Object>(core::int x) → core::List<core::String> => <core::String>["hello"];
|
||||
v = <T extends core::Object>(core::String x) → core::List<core::String> => <core::String>["hello"] as{TypeError} <S extends core::Object>(core::int) → core::List<core::String>;
|
||||
v = (<T extends core::Object>(core::String x) → core::List<core::String> => <core::String>["hello"]) as{TypeError} <S extends core::Object>(core::int) → core::List<core::String>;
|
||||
v = <T extends core::Object>(core::int x) → core::List<core::String> => <core::String>[3];
|
||||
v = <T extends core::Object>(core::int x) → core::List<core::String> {
|
||||
return <core::String>[3];
|
||||
|
@ -52,7 +52,7 @@ static method test() → void {
|
|||
x = <T extends core::Object>(core::int x) → core::int => x;
|
||||
x = <T extends core::Object>(core::int x) → core::int => x.{core::num::+}(1);
|
||||
<T extends core::Object>(core::int) → core::String y = int2String;
|
||||
y = <T extends core::Object>(core::int x) → core::int => x as{TypeError} <T extends core::Object>(core::int) → core::String;
|
||||
y = (<T extends core::Object>(core::int x) → core::int => x) as{TypeError} <T extends core::Object>(core::int) → core::String;
|
||||
y = <T extends core::Object>(core::int x) → core::String => x.substring(3);
|
||||
<T extends core::Object>(core::String) → core::String z = string2String;
|
||||
z = <T extends core::Object>(core::String x) → core::String => x.{core::String::substring}(3);
|
||||
|
|
|
@ -2,7 +2,7 @@ library test;
|
|||
import self as self;
|
||||
|
||||
static method main() → dynamic {
|
||||
dynamic v = (dynamic x) → dynamic => 1.0.call(() → dynamic {
|
||||
dynamic v = ((dynamic x) → dynamic => 1.0).call(() → dynamic {
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import self as self;
|
|||
import "dart:core" as core;
|
||||
|
||||
static method main() → dynamic {
|
||||
core::double v = (dynamic x) → core::double => 1.0.call(() → core::int {
|
||||
core::double v = ((dynamic x) → core::double => 1.0).call(() → core::int {
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ static method f() → dynamic sync* {
|
|||
static method g() → dynamic sync*
|
||||
const core::_ConstantExpressionError::•()._throw(new core::_CompileTimeError::•("pkg/front_end/testcases/regress/issue_29983.dart:11:14: Error: 'sync*' and 'async*' can't return a value.\ng() sync* => dummy;\n ^"));
|
||||
static method h() → dynamic sync* {
|
||||
() → dynamic => "return".call();
|
||||
(() → dynamic => "return").call();
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
|
|
@ -8,6 +8,6 @@ static method f() → dynamic sync* {
|
|||
static method g() → dynamic sync*
|
||||
const core::_ConstantExpressionError::•()._throw(new core::_CompileTimeError::•("pkg/front_end/testcases/regress/issue_29983.dart:11:14: Error: 'sync*' and 'async*' can't return a value.\ng() sync* => dummy;\n ^"));
|
||||
static method h() → dynamic sync* {
|
||||
() → core::String => "return".call();
|
||||
(() → core::String => "return").call();
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
|
|
@ -1725,7 +1725,7 @@ class Precedence extends ExpressionVisitor<int> {
|
|||
int visitListLiteral(ListLiteral node) => PRIMARY;
|
||||
int visitMapLiteral(MapLiteral node) => PRIMARY;
|
||||
int visitAwaitExpression(AwaitExpression node) => PREFIX;
|
||||
int visitFunctionExpression(FunctionExpression node) => PRIMARY;
|
||||
int visitFunctionExpression(FunctionExpression node) => EXPRESSION;
|
||||
int visitStringLiteral(StringLiteral node) => CALLEE;
|
||||
int visitIntLiteral(IntLiteral node) => CALLEE;
|
||||
int visitDoubleLiteral(DoubleLiteral node) => CALLEE;
|
||||
|
|
Loading…
Reference in a new issue