Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
23421875
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
23421875
编写于
10月 15, 2013
作者:
C
chegar
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
ba4f33a1
2bd6f0a7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
133 addition
and
8 deletion
+133
-8
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+27
-8
test/tools/javac/lambda/T8024947/PotentiallyAmbiguousWarningTest.java
...avac/lambda/T8024947/PotentiallyAmbiguousWarningTest.java
+97
-0
test/tools/javac/lambda/T8024947/PotentiallyAmbiguousWarningTest.out
...javac/lambda/T8024947/PotentiallyAmbiguousWarningTest.out
+9
-0
未找到文件。
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
23421875
...
...
@@ -2399,13 +2399,28 @@ public class Check {
ClashFilter
cf
=
new
ClashFilter
(
site
);
//for each method m1 that is overridden (directly or indirectly)
//by method 'sym' in 'site'...
List
<
MethodSymbol
>
potentiallyAmbiguousList
=
List
.
nil
();
boolean
overridesAny
=
false
;
for
(
Symbol
m1
:
types
.
membersClosure
(
site
,
false
).
getElementsByName
(
sym
.
name
,
cf
))
{
if
(!
sym
.
overrides
(
m1
,
site
.
tsym
,
types
,
false
))
{
checkPotentiallyAmbiguousOverloads
(
pos
,
site
,
sym
,
(
MethodSymbol
)
m1
);
continue
;
}
//...check each method m2 that is a member of 'site'
for
(
Symbol
m2
:
types
.
membersClosure
(
site
,
false
).
getElementsByName
(
sym
.
name
,
cf
))
{
if
(!
sym
.
overrides
(
m1
,
site
.
tsym
,
types
,
false
))
{
if
(
m1
==
sym
)
{
continue
;
}
if
(!
overridesAny
)
{
potentiallyAmbiguousList
=
potentiallyAmbiguousList
.
prepend
((
MethodSymbol
)
m1
);
}
continue
;
}
if
(
m1
!=
sym
)
{
overridesAny
=
true
;
potentiallyAmbiguousList
=
List
.
nil
();
}
//...check each method m2 that is a member of 'site'
for
(
Symbol
m2
:
types
.
membersClosure
(
site
,
false
).
getElementsByName
(
sym
.
name
,
cf
))
{
if
(
m2
==
m1
)
continue
;
//if (i) the signature of 'sym' is not a subsignature of m1 (seen as
//a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
...
...
@@ -2424,9 +2439,13 @@ public class Check {
}
}
}
}
if
(!
overridesAny
)
{
for
(
MethodSymbol
m:
potentiallyAmbiguousList
)
{
checkPotentiallyAmbiguousOverloads
(
pos
,
site
,
sym
,
m
);
}
}
}
/** Check that all static methods accessible from 'site' are
* mutually compatible (JLS 8.4.8).
...
...
test/tools/javac/lambda/T8024947/PotentiallyAmbiguousWarningTest.java
0 → 100644
浏览文件 @
23421875
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8024947
* @summary javac should issue the potentially ambiguous overload warning only
* where the problem appears
* @compile/fail/ref=PotentiallyAmbiguousWarningTest.out -XDrawDiagnostics -Werror -Xlint:overloads PotentiallyAmbiguousWarningTest.java
* @compile PotentiallyAmbiguousWarningTest.java
*/
import
java.util.function.*
;
public
interface
PotentiallyAmbiguousWarningTest
{
//a warning should be fired
interface
I1
{
void
foo
(
Consumer
<
Integer
>
c
);
void
foo
(
IntConsumer
c
);
}
//a warning should be fired
class
C1
{
void
foo
(
Consumer
<
Integer
>
c
)
{
}
void
foo
(
IntConsumer
c
)
{
}
}
interface
I2
{
void
foo
(
Consumer
<
Integer
>
c
);
}
//a warning should be fired, J1 is provoking the issue
interface
J1
extends
I2
{
void
foo
(
IntConsumer
c
);
}
//no warning here, the issue is introduced in I1
interface
I3
extends
I1
{}
//no warning here, the issue is introduced in I1. I4 is just overriding an existing method
interface
I4
extends
I1
{
void
foo
(
IntConsumer
c
);
}
class
C2
{
void
foo
(
Consumer
<
Integer
>
c
)
{
}
}
//a warning should be fired, D1 is provoking the issue
class
D1
extends
C2
{
void
foo
(
IntConsumer
c
)
{
}
}
//a warning should be fired, C3 is provoking the issue
class
C3
implements
I2
{
public
void
foo
(
Consumer
<
Integer
>
c
)
{
}
public
void
foo
(
IntConsumer
c
)
{
}
}
//no warning here, the issue is introduced in C1
class
C4
extends
C1
{}
//no warning here, the issue is introduced in C1. C5 is just overriding an existing method
class
C5
extends
C1
{
void
foo
(
IntConsumer
c
)
{}
}
interface
I5
<
T
>
{
void
foo
(
T
c
);
}
//a warning should be fired, J2 is provoking the issue
interface
J2
extends
I5
<
IntConsumer
>
{
void
foo
(
Consumer
<
Integer
>
c
);
}
}
test/tools/javac/lambda/T8024947/PotentiallyAmbiguousWarningTest.out
0 → 100644
浏览文件 @
23421875
PotentiallyAmbiguousWarningTest.java:39:14: compiler.warn.potentially.ambiguous.overload: foo(java.util.function.Consumer<java.lang.Integer>), PotentiallyAmbiguousWarningTest.I1, foo(java.util.function.IntConsumer), PotentiallyAmbiguousWarningTest.I1
PotentiallyAmbiguousWarningTest.java:45:14: compiler.warn.potentially.ambiguous.overload: foo(java.util.function.Consumer<java.lang.Integer>), PotentiallyAmbiguousWarningTest.C1, foo(java.util.function.IntConsumer), PotentiallyAmbiguousWarningTest.C1
PotentiallyAmbiguousWarningTest.java:55:14: compiler.warn.potentially.ambiguous.overload: foo(java.util.function.IntConsumer), PotentiallyAmbiguousWarningTest.J1, foo(java.util.function.Consumer<java.lang.Integer>), PotentiallyAmbiguousWarningTest.I2
PotentiallyAmbiguousWarningTest.java:72:14: compiler.warn.potentially.ambiguous.overload: foo(java.util.function.IntConsumer), PotentiallyAmbiguousWarningTest.D1, foo(java.util.function.Consumer<java.lang.Integer>), PotentiallyAmbiguousWarningTest.C2
PotentiallyAmbiguousWarningTest.java:78:21: compiler.warn.potentially.ambiguous.overload: foo(java.util.function.IntConsumer), PotentiallyAmbiguousWarningTest.C3, foo(java.util.function.Consumer<java.lang.Integer>), PotentiallyAmbiguousWarningTest.C3
PotentiallyAmbiguousWarningTest.java:95:14: compiler.warn.potentially.ambiguous.overload: foo(java.util.function.Consumer<java.lang.Integer>), PotentiallyAmbiguousWarningTest.J2, foo(T), PotentiallyAmbiguousWarningTest.I5
- compiler.err.warnings.and.werror
1 error
6 warnings
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录