Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
d4d132d0
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d4d132d0
编写于
4月 06, 2018
作者:
V
vromero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8199744: Incorrect compiler message for ReceiverParameter in inner class constructor
Reviewed-by: mcimadamore
上级
cb93815e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
26 deletion
+38
-26
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
...share/classes/com/sun/tools/javac/parser/JavacParser.java
+21
-22
src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
...classes/com/sun/tools/javac/resources/compiler.properties
+2
-1
test/langtools/tools/javac/T8199744/IncorrectMsgQualifiedReceiverTest.java
...ols/javac/T8199744/IncorrectMsgQualifiedReceiverTest.java
+11
-0
test/langtools/tools/javac/T8199744/IncorrectMsgQualifiedReceiverTest.out
...ools/javac/T8199744/IncorrectMsgQualifiedReceiverTest.out
+3
-0
test/langtools/tools/javac/lambda/8131742/T8131742.out
test/langtools/tools/javac/lambda/8131742/T8131742.out
+1
-3
未找到文件。
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
浏览文件 @
d4d132d0
...
...
@@ -3106,35 +3106,34 @@ public class JavacParser implements Parser {
name
=
token
.
name
();
nextToken
();
}
else
{
if
(
allowThisIdent
&&
!
lambdaParameter
)
{
if
(
allowThisIdent
||
!
lambdaParameter
||
LAX_IDENTIFIER
.
accepts
(
token
.
kind
)
||
mods
.
flags
!=
Flags
.
PARAMETER
||
mods
.
annotations
.
nonEmpty
())
{
JCExpression
pn
=
qualident
(
false
);
if
(
pn
.
hasTag
(
Tag
.
IDENT
)
&&
((
JCIdent
)
pn
).
name
!=
names
.
_this
)
{
name
=
((
JCIdent
)
pn
).
name
;
}
else
{
if
((
mods
.
flags
&
Flags
.
VARARGS
)
!=
0
)
{
log
.
error
(
token
.
pos
,
Errors
.
VarargsAndReceiver
);
}
if
(
token
.
kind
==
LBRACKET
)
{
log
.
error
(
token
.
pos
,
Errors
.
ArrayAndReceiver
);
if
(
allowThisIdent
)
{
if
((
mods
.
flags
&
Flags
.
VARARGS
)
!=
0
)
{
log
.
error
(
token
.
pos
,
Errors
.
VarargsAndReceiver
);
}
if
(
token
.
kind
==
LBRACKET
)
{
log
.
error
(
token
.
pos
,
Errors
.
ArrayAndReceiver
);
}
}
return
toP
(
F
.
at
(
pos
).
ReceiverVarDef
(
mods
,
pn
,
type
));
}
}
else
{
if
(!
lambdaParameter
||
LAX_IDENTIFIER
.
accepts
(
token
.
kind
)
||
mods
.
flags
!=
Flags
.
PARAMETER
||
mods
.
annotations
.
nonEmpty
())
{
name
=
ident
();
}
else
{
/** if it is a lambda parameter and the token kind is not an identifier,
* and there are no modifiers or annotations, then this means that the compiler
* supposed the lambda to be explicit but it can contain a mix of implicit,
* var or explicit parameters. So we assign the error name to the parameter name
* instead of issuing an error and analyze the lambda parameters as a whole at
* a higher level.
*/
name
=
names
.
empty
;
}
/** if it is a lambda parameter and the token kind is not an identifier,
* and there are no modifiers or annotations, then this means that the compiler
* supposed the lambda to be explicit but it can contain a mix of implicit,
* var or explicit parameters. So we assign the error name to the parameter name
* instead of issuing an error and analyze the lambda parameters as a whole at
* a higher level.
*/
name
=
names
.
empty
;
}
}
if
((
mods
.
flags
&
Flags
.
VARARGS
)
!=
0
&&
...
...
@@ -3905,7 +3904,7 @@ public class JavacParser implements Parser {
JCVariableDecl
lastParam
;
accept
(
LPAREN
);
if
(
token
.
kind
!=
RPAREN
)
{
this
.
allowThisIdent
=
true
;
this
.
allowThisIdent
=
!
lambdaParameters
;
lastParam
=
formalParameter
(
lambdaParameters
);
if
(
lastParam
.
nameexpr
!=
null
)
{
this
.
receiverParam
=
lastParam
;
...
...
src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
浏览文件 @
d4d132d0
...
...
@@ -2740,7 +2740,8 @@ compiler.err.assert.as.identifier=\
# TODO 308: make a better error message
compiler.err.this.as.identifier
=
\
as of release 8, ''this'' is allowed as the parameter name for the receiver type only, which has to be the first parameter
as of release 8, ''this'' is allowed as the parameter name for the receiver type only
\n\
which has to be the first parameter, and cannot be a lambda parameter
compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class
=
\
receiver parameter not applicable for constructor of top-level class
...
...
test/langtools/tools/javac/T8199744/IncorrectMsgQualifiedReceiverTest.java
0 → 100644
浏览文件 @
d4d132d0
/*
* @test /nodynamiccopyright/
* @bug 8199744
* @summary Incorrect compiler message for ReceiverParameter in inner class constructor
* @compile/fail/ref=IncorrectMsgQualifiedReceiverTest.out -XDrawDiagnostics IncorrectMsgQualifiedReceiverTest.java
*/
class
IncorrectMsgQualifiedReceiverTest
{
void
foo
(
int
any
,
IncorrectMsgQualifiedReceiverTest
IncorrectMsgQualifiedReceiverTest
.
this
)
{}
void
bar
(
int
any
,
IncorrectMsgQualifiedReceiverTest
IncorrectMsgQualifiedReceiverTest
.
this
,
int
another
)
{}
}
test/langtools/tools/javac/T8199744/IncorrectMsgQualifiedReceiverTest.out
0 → 100644
浏览文件 @
d4d132d0
IncorrectMsgQualifiedReceiverTest.java:9:91: compiler.err.this.as.identifier
IncorrectMsgQualifiedReceiverTest.java:10:91: compiler.err.this.as.identifier
2 errors
test/langtools/tools/javac/lambda/8131742/T8131742.out
浏览文件 @
d4d132d0
T8131742.java:8:38: compiler.err.expected3: ',', ')', '['
T8131742.java:8:39: compiler.err.this.as.identifier
T8131742.java:8:43: compiler.err.expected: ';'
3 errors
1 error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录