Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
cb629213
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看板
提交
cb629213
编写于
4月 12, 2013
作者:
J
jfranck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7015104: use new subtype of TypeSymbol for type parameters
Reviewed-by: jjg, mcimadamore
上级
7881ecdb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
41 deletion
+42
-41
src/share/classes/com/sun/tools/javac/code/Symbol.java
src/share/classes/com/sun/tools/javac/code/Symbol.java
+35
-33
src/share/classes/com/sun/tools/javac/code/Symtab.java
src/share/classes/com/sun/tools/javac/code/Symtab.java
+1
-2
src/share/classes/com/sun/tools/javac/code/Type.java
src/share/classes/com/sun/tools/javac/code/Type.java
+1
-1
src/share/classes/com/sun/tools/javac/comp/Infer.java
src/share/classes/com/sun/tools/javac/comp/Infer.java
+1
-1
test/tools/javac/scope/7017664/CompoundScopeTest.java
test/tools/javac/scope/7017664/CompoundScopeTest.java
+2
-2
test/tools/javac/types/TypeHarness.java
test/tools/javac/types/TypeHarness.java
+2
-2
未找到文件。
src/share/classes/com/sun/tools/javac/code/Symbol.java
浏览文件 @
cb629213
...
...
@@ -496,10 +496,11 @@ public abstract class Symbol implements Element {
return
List
.
nil
();
}
public
List
<
TypeSymbol
>
getTypeParameters
()
{
ListBuffer
<
TypeSymbol
>
l
=
ListBuffer
.
lb
();
public
List
<
Type
Variable
Symbol
>
getTypeParameters
()
{
ListBuffer
<
Type
Variable
Symbol
>
l
=
ListBuffer
.
lb
();
for
(
Type
t
:
type
.
getTypeArguments
())
{
l
.
append
(
t
.
tsym
);
Assert
.
check
(
t
.
tsym
.
getKind
()
==
ElementKind
.
TYPE_PARAMETER
);
l
.
append
((
TypeVariableSymbol
)
t
.
tsym
);
}
return
l
.
toList
();
}
...
...
@@ -546,19 +547,12 @@ public abstract class Symbol implements Element {
}
}
/** A class for type symbols. Type variables are represented by instances
* of this class, classes and packages by instances of subclasses.
/** A base class for Symbols representing types.
*/
public
static
class
TypeSymbol
extends
Symbol
implements
TypeParameterElement
{
// Implements TypeParameterElement because type parameters don't
// have their own TypeSymbol subclass.
// TODO: type parameters should have their own TypeSymbol subclass
public
TypeSymbol
(
long
flags
,
Name
name
,
Type
type
,
Symbol
owner
)
{
super
(
TYP
,
flags
,
name
,
type
,
owner
);
public
static
abstract
class
TypeSymbol
extends
Symbol
{
public
TypeSymbol
(
int
kind
,
long
flags
,
Name
name
,
Type
type
,
Symbol
owner
)
{
super
(
kind
,
flags
,
name
,
type
,
owner
);
}
/** form a fully qualified name from a name and an owner
*/
static
public
Name
formFullName
(
Name
name
,
Symbol
owner
)
{
...
...
@@ -610,11 +604,7 @@ public abstract class Symbol implements Element {
return
this
.
type
.
hasTag
(
TYPEVAR
);
}
// For type params; overridden in subclasses.
public
ElementKind
getKind
()
{
return
ElementKind
.
TYPE_PARAMETER
;
}
@Override
public
java
.
util
.
List
<
Symbol
>
getEnclosedElements
()
{
List
<
Symbol
>
list
=
List
.
nil
();
if
(
kind
==
TYP
&&
type
.
hasTag
(
TYPEVAR
))
{
...
...
@@ -627,21 +617,29 @@ public abstract class Symbol implements Element {
return
list
;
}
// For type params.
// Perhaps not needed if getEnclosingElement can be spec'ed
// to do the same thing.
// TODO: getGenericElement() might not be needed
public
Symbol
getGenericElement
()
{
return
owner
;
@Override
public
<
R
,
P
>
R
accept
(
Symbol
.
Visitor
<
R
,
P
>
v
,
P
p
)
{
return
v
.
visitTypeSymbol
(
this
,
p
);
}
}
public
<
R
,
P
>
R
accept
(
ElementVisitor
<
R
,
P
>
v
,
P
p
)
{
Assert
.
check
(
type
.
hasTag
(
TYPEVAR
));
// else override will be invoked
return
v
.
visitTypeParameter
(
this
,
p
);
/**
* Type variables are represented by instances of this class.
*/
public
static
class
TypeVariableSymbol
extends
TypeSymbol
implements
TypeParameterElement
{
public
TypeVariableSymbol
(
long
flags
,
Name
name
,
Type
type
,
Symbol
owner
)
{
super
(
TYP
,
flags
,
name
,
type
,
owner
);
}
public
<
R
,
P
>
R
accept
(
Symbol
.
Visitor
<
R
,
P
>
v
,
P
p
)
{
return
v
.
visitTypeSymbol
(
this
,
p
);
public
ElementKind
getKind
()
{
return
ElementKind
.
TYPE_PARAMETER
;
}
@Override
public
Symbol
getGenericElement
()
{
return
owner
;
}
public
List
<
Type
>
getBounds
()
{
...
...
@@ -658,6 +656,11 @@ public abstract class Symbol implements Element {
return
ct
.
interfaces_field
;
}
}
@Override
public
<
R
,
P
>
R
accept
(
ElementVisitor
<
R
,
P
>
v
,
P
p
)
{
return
v
.
visitTypeParameter
(
this
,
p
);
}
}
/** A class for package symbols
...
...
@@ -670,8 +673,7 @@ public abstract class Symbol implements Element {
public
ClassSymbol
package_info
;
// see bug 6443073
public
PackageSymbol
(
Name
name
,
Type
type
,
Symbol
owner
)
{
super
(
0
,
name
,
type
,
owner
);
this
.
kind
=
PCK
;
super
(
PCK
,
0
,
name
,
type
,
owner
);
this
.
members_field
=
null
;
this
.
fullname
=
formFullName
(
name
,
owner
);
}
...
...
@@ -783,7 +785,7 @@ public abstract class Symbol implements Element {
public
Pool
pool
;
public
ClassSymbol
(
long
flags
,
Name
name
,
Type
type
,
Symbol
owner
)
{
super
(
flags
,
name
,
type
,
owner
);
super
(
TYP
,
flags
,
name
,
type
,
owner
);
this
.
members_field
=
null
;
this
.
fullname
=
formFullName
(
name
,
owner
);
this
.
flatname
=
formFlatName
(
name
,
owner
);
...
...
src/share/classes/com/sun/tools/javac/code/Symtab.java
浏览文件 @
cb629213
...
...
@@ -404,12 +404,11 @@ public class Symtab {
return
messages
.
getLocalizedString
(
"compiler.misc.unnamed.package"
);
}
};
noSymbol
=
new
TypeSymbol
(
0
,
names
.
empty
,
Type
.
noType
,
rootPackage
)
{
noSymbol
=
new
TypeSymbol
(
Kinds
.
NIL
,
0
,
names
.
empty
,
Type
.
noType
,
rootPackage
)
{
public
<
R
,
P
>
R
accept
(
ElementVisitor
<
R
,
P
>
v
,
P
p
)
{
return
v
.
visitUnknown
(
this
,
p
);
}
};
noSymbol
.
kind
=
Kinds
.
NIL
;
// create the error symbols
errSymbol
=
new
ClassSymbol
(
PUBLIC
|
STATIC
|
ACYCLIC
,
names
.
any
,
null
,
rootPackage
);
...
...
src/share/classes/com/sun/tools/javac/code/Type.java
浏览文件 @
cb629213
...
...
@@ -1145,7 +1145,7 @@ public class Type implements PrimitiveType {
public
TypeVar
(
Name
name
,
Symbol
owner
,
Type
lower
)
{
super
(
TYPEVAR
,
null
);
tsym
=
new
TypeSymbol
(
0
,
name
,
this
,
owner
);
tsym
=
new
Type
Variable
Symbol
(
0
,
name
,
this
,
owner
);
this
.
lower
=
lower
;
}
...
...
src/share/classes/com/sun/tools/javac/comp/Infer.java
浏览文件 @
cb629213
...
...
@@ -262,7 +262,7 @@ public class Infer {
UndetVar
uv
=
(
UndetVar
)
inferenceContext
.
asFree
(
t
);
List
<
Type
>
upperBounds
=
uv
.
getBounds
(
InferenceBound
.
UPPER
);
if
(
Type
.
containsAny
(
upperBounds
,
vars
))
{
TypeSymbol
fresh_tvar
=
new
TypeSymbol
(
Flags
.
SYNTHETIC
,
uv
.
qtype
.
tsym
.
name
,
null
,
uv
.
qtype
.
tsym
.
owner
);
TypeSymbol
fresh_tvar
=
new
Type
Variable
Symbol
(
Flags
.
SYNTHETIC
,
uv
.
qtype
.
tsym
.
name
,
null
,
uv
.
qtype
.
tsym
.
owner
);
fresh_tvar
.
type
=
new
TypeVar
(
fresh_tvar
,
types
.
makeCompoundType
(
uv
.
getBounds
(
InferenceBound
.
UPPER
)),
null
);
todo
.
append
(
uv
);
uv
.
inst
=
fresh_tvar
.
type
;
...
...
test/tools/javac/scope/7017664/CompoundScopeTest.java
浏览文件 @
cb629213
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
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
...
...
@@ -147,7 +147,7 @@ public class CompoundScopeTest {
Scope
createScope
(
int
nelems
)
{
Scope
s
=
new
Scope
(
symtab
.
noSymbol
);
for
(
int
i
=
0
;
i
<
nelems
;
i
++)
{
Symbol
sym
=
new
TypeSymbol
(
0
,
names
.
fromString
(
"s"
+
i
),
null
,
null
);
Symbol
sym
=
new
Type
Variable
Symbol
(
0
,
names
.
fromString
(
"s"
+
i
),
null
,
null
);
s
.
enter
(
sym
);
elems
=
elems
.
prepend
(
sym
);
List
<
Symbol
>
shadowed
=
shadowedMap
.
get
(
sym
.
name
);
...
...
test/tools/javac/types/TypeHarness.java
浏览文件 @
cb629213
/*
* Copyright (c) 2010, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
3
, 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
...
...
@@ -309,7 +309,7 @@ public class TypeHarness {
}
public
TypeVar
TypeVariable
(
Type
bound
)
{
TypeSymbol
tvsym
=
new
TypeSymbol
(
0
,
syntheticName
(),
null
,
predef
.
noSymbol
);
TypeSymbol
tvsym
=
new
Type
Variable
Symbol
(
0
,
syntheticName
(),
null
,
predef
.
noSymbol
);
tvsym
.
type
=
new
TypeVar
(
tvsym
,
bound
,
null
);
return
(
TypeVar
)
tvsym
.
type
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录