Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
67ca0496
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
67ca0496
编写于
12月 19, 2011
作者:
S
Stepan Koltsov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TypeParameterDescriptor.initialized
Internal state checks Also add a missing initialization
上级
dfdd5959
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
7 deletion
+62
-7
compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java
...tbrains/jet/lang/resolve/java/JavaDescriptorResolver.java
+8
-3
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor.java
...tbrains/jet/lang/descriptors/TypeParameterDescriptor.java
+50
-1
compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java
...rc/org/jetbrains/jet/lang/resolve/DescriptorResolver.java
+3
-3
compiler/frontend/src/org/jetbrains/jet/lang/types/DescriptorSubstitutor.java
...c/org/jetbrains/jet/lang/types/DescriptorSubstitutor.java
+1
-0
未找到文件。
compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java
浏览文件 @
67ca0496
...
...
@@ -334,6 +334,7 @@ public class JavaDescriptorResolver {
typeParameterDescriptor
.
addUpperBound
(
semanticServices
.
getTypeTransformer
().
transformToType
(
referencedType
));
}
}
typeParameterDescriptor
.
setInitialized
();
}
private
void
initializeTypeParameters
(
PsiTypeParameterListOwner
typeParameterListOwner
)
{
...
...
@@ -625,7 +626,9 @@ public class JavaDescriptorResolver {
if
(
attributeValue
!=
null
)
{
String
typeParametersString
=
(
String
)
attributeValue
.
getValue
();
if
(
typeParametersString
!=
null
)
{
return
resolveMethodTypeParametersFromJetSignature
(
typeParametersString
,
functionDescriptorImpl
);
List
<
TypeParameterDescriptor
>
r
=
resolveMethodTypeParametersFromJetSignature
(
typeParametersString
,
method
,
functionDescriptorImpl
);
initializeTypeParameters
(
method
);
return
r
;
}
}
}
...
...
@@ -637,9 +640,9 @@ public class JavaDescriptorResolver {
}
/**
* @see #resolveClassTypeParametersFromJetSignature(String,
JavaClassDescriptor)
* @see #resolveClassTypeParametersFromJetSignature(String,
com.intellij.psi.PsiClass, JavaClassDescriptor)
*/
private
List
<
TypeParameterDescriptor
>
resolveMethodTypeParametersFromJetSignature
(
String
jetSignature
,
final
FunctionDescriptor
functionDescriptor
)
{
private
List
<
TypeParameterDescriptor
>
resolveMethodTypeParametersFromJetSignature
(
String
jetSignature
,
final
PsiMethod
method
,
final
FunctionDescriptor
functionDescriptor
)
{
final
List
<
TypeParameterDescriptor
>
r
=
new
ArrayList
<
TypeParameterDescriptor
>();
new
JetSignatureReader
(
jetSignature
).
acceptFormalTypeParametersOnly
(
new
JetSignatureExceptionsAdapter
()
{
@Override
...
...
@@ -677,6 +680,8 @@ public class JavaDescriptorResolver {
JetSignatureUtils
.
translateVariance
(
variance
),
name
,
++
index
);
PsiTypeParameter
psiTypeParameter
=
getPsiTypeParameterByName
(
method
,
method
.
getName
(),
name
);
typeParameterDescriptorCache
.
put
(
psiTypeParameter
,
typeParameter
);
r
.
add
(
typeParameter
);
}
};
...
...
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor.java
浏览文件 @
67ca0496
...
...
@@ -28,6 +28,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
int
index
)
{
TypeParameterDescriptor
typeParameterDescriptor
=
createForFurtherModification
(
containingDeclaration
,
annotations
,
reified
,
variance
,
name
,
index
);
typeParameterDescriptor
.
addUpperBound
(
JetStandardClasses
.
getDefaultBound
());
typeParameterDescriptor
.
setInitialized
();
return
typeParameterDescriptor
;
}
...
...
@@ -52,6 +53,8 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
private
final
boolean
reified
;
private
boolean
initialized
=
false
;
private
TypeParameterDescriptor
(
@NotNull
DeclarationDescriptor
containingDeclaration
,
@NotNull
List
<
AnnotationDescriptor
>
annotations
,
...
...
@@ -74,25 +77,61 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
upperBounds
);
}
public
void
setInitialized
()
{
if
(
initialized
)
{
throw
new
IllegalStateException
();
}
initialized
=
true
;
}
private
void
checkInitialized
()
{
if
(!
initialized
)
{
throw
new
IllegalStateException
();
}
}
private
void
checkUninitialized
()
{
if
(
initialized
)
{
throw
new
IllegalStateException
();
}
}
public
boolean
isReified
()
{
checkInitialized
();
return
reified
;
}
public
Variance
getVariance
()
{
checkInitialized
();
return
variance
;
}
public
void
addUpperBound
(
@NotNull
JetType
bound
)
{
checkUninitialized
();
doAddUpperBound
(
bound
);
}
private
void
doAddUpperBound
(
JetType
bound
)
{
upperBounds
.
add
(
bound
);
// TODO : Duplicates?
}
public
void
addDefaultUpperBound
()
{
checkUninitialized
();
if
(
upperBounds
.
isEmpty
())
{
doAddUpperBound
(
JetStandardClasses
.
getDefaultBound
());
}
}
@NotNull
public
Set
<
JetType
>
getUpperBounds
()
{
checkInitialized
();
return
upperBounds
;
}
@NotNull
public
JetType
getUpperBoundsAsType
()
{
checkInitialized
();
if
(
upperBoundsAsType
==
null
)
{
assert
upperBounds
!=
null
:
"Upper bound list is null in "
+
getName
();
assert
upperBounds
.
size
()
>
0
:
"Upper bound list is empty in "
+
getName
();
...
...
@@ -106,11 +145,13 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
@NotNull
public
Set
<
JetType
>
getLowerBounds
()
{
//checkInitialized();
return
Collections
.
singleton
(
JetStandardClasses
.
getNothingType
());
}
@NotNull
public
JetType
getLowerBoundsAsType
()
{
checkInitialized
();
return
JetStandardClasses
.
getNothingType
();
}
...
...
@@ -118,6 +159,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
@NotNull
@Override
public
TypeConstructor
getTypeConstructor
()
{
//checkInitialized();
return
typeConstructor
;
}
...
...
@@ -135,12 +177,14 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
@Override
public
<
R
,
D
>
R
accept
(
DeclarationDescriptorVisitor
<
R
,
D
>
visitor
,
D
data
)
{
checkInitialized
();
return
visitor
.
visitTypeParameterDescriptor
(
this
,
data
);
}
@NotNull
@Override
public
JetType
getDefaultType
()
{
//checkInitialized();
if
(
defaultType
==
null
)
{
defaultType
=
new
JetTypeImpl
(
Collections
.<
AnnotationDescriptor
>
emptyList
(),
...
...
@@ -159,6 +203,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
@Override
public
JetType
getClassObjectType
()
{
checkInitialized
();
if
(
classObjectUpperBounds
.
isEmpty
())
return
null
;
if
(
classObjectBoundsAsType
==
null
)
{
...
...
@@ -176,15 +221,19 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
}
public
void
addClassObjectBound
(
@NotNull
JetType
bound
)
{
checkUninitialized
();
classObjectUpperBounds
.
add
(
bound
);
// TODO : Duplicates?
}
public
int
getIndex
()
{
checkInitialized
();
return
index
;
}
@NotNull
public
TypeParameterDescriptor
copy
(
@NotNull
DeclarationDescriptor
newOwner
)
{
return
new
TypeParameterDescriptor
(
newOwner
,
Lists
.
newArrayList
(
getAnnotations
()),
reified
,
variance
,
getName
(),
index
);
TypeParameterDescriptor
copy
=
new
TypeParameterDescriptor
(
newOwner
,
Lists
.
newArrayList
(
getAnnotations
()),
reified
,
variance
,
getName
(),
index
);
copy
.
initialized
=
this
.
initialized
;
return
copy
;
}
}
compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java
浏览文件 @
67ca0496
...
...
@@ -381,9 +381,9 @@ public class DescriptorResolver {
}
for
(
TypeParameterDescriptor
parameter
:
parameters
)
{
if
(
parameter
.
getUpperBounds
().
isEmpty
())
{
parameter
.
addUpperBound
(
JetStandardClasses
.
getDefaultBound
());
}
parameter
.
addDefaultUpperBound
();
parameter
.
setInitialized
();
if
(
JetStandardClasses
.
isNothing
(
parameter
.
getUpperBoundsAsType
()))
{
PsiElement
nameIdentifier
=
typeParameters
.
get
(
parameter
.
getIndex
()).
getNameIdentifier
();
...
...
compiler/frontend/src/org/jetbrains/jet/lang/types/DescriptorSubstitutor.java
浏览文件 @
67ca0496
...
...
@@ -44,6 +44,7 @@ public class DescriptorSubstitutor {
descriptor
.
getVariance
(),
descriptor
.
getName
(),
descriptor
.
getIndex
());
substituted
.
setInitialized
();
mutableSubstitution
.
put
(
descriptor
.
getTypeConstructor
(),
new
TypeProjection
(
substituted
.
getDefaultType
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录