Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
6158c306
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,发现更多精彩内容 >>
提交
6158c306
编写于
9月 06, 2011
作者:
A
Andrey Breslav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Annotation resolver beautified a bit
上级
67925fcd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
108 addition
and
47 deletion
+108
-47
idea/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java
...etbrains/jet/lang/descriptors/MutableClassDescriptor.java
+0
-1
idea/src/org/jetbrains/jet/lang/psi/JetModifierList.java
idea/src/org/jetbrains/jet/lang/psi/JetModifierList.java
+3
-1
idea/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
...rc/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
+17
-7
idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java
idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java
+2
-0
idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java
idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java
+2
-0
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
+42
-5
idea/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
...rc/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
+38
-33
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
+4
-0
未找到文件。
idea/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java
浏览文件 @
6158c306
...
@@ -176,7 +176,6 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
...
@@ -176,7 +176,6 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
supertypes
);
supertypes
);
scopeForMemberResolution
.
setThisType
(
getDefaultType
());
scopeForMemberResolution
.
setThisType
(
getDefaultType
());
for
(
FunctionDescriptor
functionDescriptor
:
constructors
.
getFunctionDescriptors
())
{
for
(
FunctionDescriptor
functionDescriptor
:
constructors
.
getFunctionDescriptors
())
{
// functionDescriptor.getTypeParameters().addAll(typeParameters);
((
ConstructorDescriptorImpl
)
functionDescriptor
).
setReturnType
(
getDefaultType
());
((
ConstructorDescriptorImpl
)
functionDescriptor
).
setReturnType
(
getDefaultType
());
}
}
}
}
...
...
idea/src/org/jetbrains/jet/lang/psi/JetModifierList.java
浏览文件 @
6158c306
package
org.jetbrains.jet.lang.psi
;
package
org.jetbrains.jet.lang.psi
;
import
com.google.common.collect.Lists
;
import
com.intellij.lang.ASTNode
;
import
com.intellij.lang.ASTNode
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.annotations.Nullable
;
...
@@ -34,7 +35,8 @@ public class JetModifierList extends JetElement {
...
@@ -34,7 +35,8 @@ public class JetModifierList extends JetElement {
}
}
public
List
<
JetAnnotationEntry
>
getAnnotationEntries
()
{
public
List
<
JetAnnotationEntry
>
getAnnotationEntries
()
{
List
<
JetAnnotationEntry
>
answer
=
null
;
List
<
JetAnnotationEntry
>
entries
=
findChildrenByType
(
JetNodeTypes
.
ANNOTATION_ENTRY
);
List
<
JetAnnotationEntry
>
answer
=
entries
.
isEmpty
()
?
null
:
Lists
.
newArrayList
(
entries
);
for
(
JetAnnotation
annotation
:
getAnnotations
())
{
for
(
JetAnnotation
annotation
:
getAnnotations
())
{
if
(
answer
==
null
)
answer
=
new
ArrayList
<
JetAnnotationEntry
>();
if
(
answer
==
null
)
answer
=
new
ArrayList
<
JetAnnotationEntry
>();
answer
.
addAll
(
annotation
.
getEntries
());
answer
.
addAll
(
annotation
.
getEntries
());
...
...
idea/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
浏览文件 @
6158c306
...
@@ -4,25 +4,31 @@ import com.google.common.collect.Lists;
...
@@ -4,25 +4,31 @@ import com.google.common.collect.Lists;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.JetSemanticServices
;
import
org.jetbrains.jet.lang.JetSemanticServices
;
import
org.jetbrains.jet.lang.cfg.JetFlowInformationProvider
;
import
org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
;
import
org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
;
import
org.jetbrains.jet.lang.psi.JetAnnotationEntry
;
import
org.jetbrains.jet.lang.psi.JetAnnotationEntry
;
import
org.jetbrains.jet.lang.psi.JetExpression
;
import
org.jetbrains.jet.lang.psi.JetExpression
;
import
org.jetbrains.jet.lang.psi.JetModifierList
;
import
org.jetbrains.jet.lang.psi.JetModifierList
;
import
org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant
;
import
org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant
;
import
org.jetbrains.jet.lang.types.ErrorUtils
;
import
org.jetbrains.jet.lang.types.JetType
;
import
org.jetbrains.jet.lang.types.JetType
;
import
org.jetbrains.jet.lang.types.JetTypeInferrer
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
jetbrains
.
jet
.
lang
.
types
.
JetTypeInferrer
.
NO_EXPECTED_TYPE
;
/**
/**
* @author abreslav
* @author abreslav
*/
*/
public
class
AnnotationResolver
{
public
class
AnnotationResolver
{
private
final
BindingTrace
trace
;
private
final
BindingTrace
trace
;
private
final
JetTypeInferrer
typeInferrer
;
public
AnnotationResolver
(
JetSemanticServices
semanticServices
,
BindingTrace
trace
)
{
public
AnnotationResolver
(
JetSemanticServices
semanticServices
,
BindingTrace
trace
)
{
this
.
typeInferrer
=
new
JetTypeInferrer
(
JetFlowInformationProvider
.
THROW_EXCEPTION
,
semanticServices
);
this
.
trace
=
trace
;
this
.
trace
=
trace
;
}
}
...
@@ -30,15 +36,19 @@ public class AnnotationResolver {
...
@@ -30,15 +36,19 @@ public class AnnotationResolver {
public
List
<
AnnotationDescriptor
>
resolveAnnotations
(
@NotNull
JetScope
scope
,
@NotNull
List
<
JetAnnotationEntry
>
annotationEntryElements
)
{
public
List
<
AnnotationDescriptor
>
resolveAnnotations
(
@NotNull
JetScope
scope
,
@NotNull
List
<
JetAnnotationEntry
>
annotationEntryElements
)
{
if
(
annotationEntryElements
.
isEmpty
())
return
Collections
.
emptyList
();
if
(
annotationEntryElements
.
isEmpty
())
return
Collections
.
emptyList
();
List
<
AnnotationDescriptor
>
result
=
Lists
.
newArrayList
();
List
<
AnnotationDescriptor
>
result
=
Lists
.
newArrayList
();
// for (JetAnnotationEntry entryElement : annotationEntryElements) {
for
(
JetAnnotationEntry
entryElement
:
annotationEntryElements
)
{
// JetType jetType = typeInferrer.checkTypeInitializerCall(scope, entryElement.getTypeReference(), entryElement);
AnnotationDescriptor
descriptor
=
new
AnnotationDescriptor
();
// AnnotationDescriptor descriptor = new AnnotationDescriptor();
resolveAnnotationStub
(
scope
,
entryElement
,
descriptor
);
// descriptor.setAnnotationType(jetType);
result
.
add
(
descriptor
);
// result.add(descriptor);
}
// }
return
result
;
return
result
;
}
}
public
void
resolveAnnotationStub
(
@NotNull
JetScope
scope
,
@NotNull
JetAnnotationEntry
entryElement
,
@NotNull
AnnotationDescriptor
descriptor
)
{
JetType
jetType
=
typeInferrer
.
getCallResolver
().
resolveCall
(
trace
,
scope
,
null
,
entryElement
,
NO_EXPECTED_TYPE
);
descriptor
.
setAnnotationType
(
jetType
==
null
?
ErrorUtils
.
createErrorType
(
"Unresolved annotation type"
)
:
jetType
);
}
@NotNull
@NotNull
public
List
<
AnnotationDescriptor
>
resolveAnnotations
(
@NotNull
JetScope
scope
,
@Nullable
JetModifierList
modifierList
)
{
public
List
<
AnnotationDescriptor
>
resolveAnnotations
(
@NotNull
JetScope
scope
,
@Nullable
JetModifierList
modifierList
)
{
if
(
modifierList
==
null
)
{
if
(
modifierList
==
null
)
{
...
...
idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java
浏览文件 @
6158c306
package
org.jetbrains.jet.lang.resolve
;
package
org.jetbrains.jet.lang.resolve
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiElement
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.JetDiagnostic
;
import
org.jetbrains.jet.lang.JetDiagnostic
;
import
org.jetbrains.jet.lang.descriptors.*
;
import
org.jetbrains.jet.lang.descriptors.*
;
import
org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
;
import
org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
;
...
@@ -112,5 +113,6 @@ public interface BindingContext {
...
@@ -112,5 +113,6 @@ public interface BindingContext {
Collection
<
JetDiagnostic
>
getDiagnostics
();
Collection
<
JetDiagnostic
>
getDiagnostics
();
@Nullable
<
K
,
V
>
V
get
(
ReadOnlySlice
<
K
,
V
>
slice
,
K
key
);
<
K
,
V
>
V
get
(
ReadOnlySlice
<
K
,
V
>
slice
,
K
key
);
}
}
idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java
浏览文件 @
6158c306
package
org.jetbrains.jet.lang.resolve
;
package
org.jetbrains.jet.lang.resolve
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.ErrorHandler
;
import
org.jetbrains.jet.lang.ErrorHandler
;
import
org.jetbrains.jet.util.slicedmap.ReadOnlySlice
;
import
org.jetbrains.jet.util.slicedmap.ReadOnlySlice
;
import
org.jetbrains.jet.util.slicedmap.WritableSlice
;
import
org.jetbrains.jet.util.slicedmap.WritableSlice
;
...
@@ -20,5 +21,6 @@ public interface BindingTrace {
...
@@ -20,5 +21,6 @@ public interface BindingTrace {
// Writes TRUE for a boolean value
// Writes TRUE for a boolean value
<
K
>
void
record
(
WritableSlice
<
K
,
Boolean
>
slice
,
K
key
);
<
K
>
void
record
(
WritableSlice
<
K
,
Boolean
>
slice
,
K
key
);
@Nullable
<
K
,
V
>
V
get
(
ReadOnlySlice
<
K
,
V
>
slice
,
K
key
);
<
K
,
V
>
V
get
(
ReadOnlySlice
<
K
,
V
>
slice
,
K
key
);
}
}
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
浏览文件 @
6158c306
...
@@ -17,6 +17,7 @@ import org.jetbrains.jet.util.slicedmap.WritableSlice;
...
@@ -17,6 +17,7 @@ import org.jetbrains.jet.util.slicedmap.WritableSlice;
import
java.util.*
;
import
java.util.*
;
import
static
org
.
jetbrains
.
jet
.
lang
.
resolve
.
BindingContext
.
ANNOTATION
;
import
static
org
.
jetbrains
.
jet
.
lang
.
types
.
JetTypeInferrer
.
NO_EXPECTED_TYPE
;
import
static
org
.
jetbrains
.
jet
.
lang
.
types
.
JetTypeInferrer
.
NO_EXPECTED_TYPE
;
/**
/**
...
@@ -40,6 +41,7 @@ public class TopDownAnalyzer {
...
@@ -40,6 +41,7 @@ public class TopDownAnalyzer {
private
final
BindingTrace
trace
;
private
final
BindingTrace
trace
;
private
final
BindingTraceAdapter
traceForConstructors
;
private
final
BindingTraceAdapter
traceForConstructors
;
private
final
BindingTraceAdapter
traceForMembers
;
private
final
BindingTraceAdapter
traceForMembers
;
private
final
AnnotationResolver
annotationResolver
;
public
TopDownAnalyzer
(
JetSemanticServices
semanticServices
,
@NotNull
BindingTrace
bindingTrace
)
{
public
TopDownAnalyzer
(
JetSemanticServices
semanticServices
,
@NotNull
BindingTrace
bindingTrace
)
{
this
.
semanticServices
=
semanticServices
;
this
.
semanticServices
=
semanticServices
;
...
@@ -73,6 +75,8 @@ public class TopDownAnalyzer {
...
@@ -73,6 +75,8 @@ public class TopDownAnalyzer {
}
}
}
}
});
});
this
.
annotationResolver
=
new
AnnotationResolver
(
semanticServices
,
trace
);
}
}
public
void
processObject
(
@NotNull
JetScope
outerScope
,
@NotNull
DeclarationDescriptor
containingDeclaration
,
@NotNull
JetObjectDeclaration
object
)
{
public
void
processObject
(
@NotNull
JetScope
outerScope
,
@NotNull
DeclarationDescriptor
containingDeclaration
,
@NotNull
JetObjectDeclaration
object
)
{
...
@@ -117,7 +121,11 @@ public class TopDownAnalyzer {
...
@@ -117,7 +121,11 @@ public class TopDownAnalyzer {
resolveTypesInClassHeaders
();
// Generic bounds and types in supertype lists (no expressions or constructor resolution)
resolveTypesInClassHeaders
();
// Generic bounds and types in supertype lists (no expressions or constructor resolution)
checkGenericBoundsInClassHeaders
();
// For the types resolved so far
checkGenericBoundsInClassHeaders
();
// For the types resolved so far
resolveFunctionAndPropertyHeaders
();
// Constructor headers are resolved as well
resolveConstructorHeaders
();
resolveAnnotationStubsOnClassesAndConstructors
();
resolveFunctionAndPropertyHeaders
();
resolveBehaviorDeclarationBodies
();
resolveBehaviorDeclarationBodies
();
}
}
...
@@ -372,6 +380,35 @@ public class TopDownAnalyzer {
...
@@ -372,6 +380,35 @@ public class TopDownAnalyzer {
}
}
}
}
private
void
resolveConstructorHeaders
()
{
for
(
Map
.
Entry
<
JetClass
,
MutableClassDescriptor
>
entry
:
classes
.
entrySet
())
{
JetClass
jetClass
=
entry
.
getKey
();
MutableClassDescriptor
classDescriptor
=
entry
.
getValue
();
processPrimaryConstructor
(
classDescriptor
,
jetClass
);
for
(
JetConstructor
jetConstructor
:
jetClass
.
getSecondaryConstructors
())
{
processSecondaryConstructor
(
classDescriptor
,
jetConstructor
);
}
}
}
private
void
resolveAnnotationStubsOnClassesAndConstructors
()
{
for
(
Map
.
Entry
<
JetClass
,
MutableClassDescriptor
>
entry
:
classes
.
entrySet
())
{
JetClass
jetClass
=
entry
.
getKey
();
MutableClassDescriptor
mutableClassDescriptor
=
entry
.
getValue
();
JetModifierList
modifierList
=
jetClass
.
getModifierList
();
if
(
modifierList
!=
null
)
{
List
<
JetAnnotationEntry
>
annotationEntries
=
modifierList
.
getAnnotationEntries
();
for
(
JetAnnotationEntry
annotationEntry
:
annotationEntries
)
{
AnnotationDescriptor
annotationDescriptor
=
trace
.
get
(
ANNOTATION
,
annotationEntry
);
annotationResolver
.
resolveAnnotationStub
(
mutableClassDescriptor
.
getScopeForSupertypeResolution
(),
annotationEntry
,
annotationDescriptor
);
}
}
}
}
private
void
resolveFunctionAndPropertyHeaders
()
{
private
void
resolveFunctionAndPropertyHeaders
()
{
for
(
Map
.
Entry
<
JetNamespace
,
WritableScope
>
entry
:
namespaceScopes
.
entrySet
())
{
for
(
Map
.
Entry
<
JetNamespace
,
WritableScope
>
entry
:
namespaceScopes
.
entrySet
())
{
JetNamespace
namespace
=
entry
.
getKey
();
JetNamespace
namespace
=
entry
.
getKey
();
...
@@ -385,10 +422,10 @@ public class TopDownAnalyzer {
...
@@ -385,10 +422,10 @@ public class TopDownAnalyzer {
MutableClassDescriptor
classDescriptor
=
entry
.
getValue
();
MutableClassDescriptor
classDescriptor
=
entry
.
getValue
();
resolveFunctionAndPropertyHeaders
(
jetClass
.
getDeclarations
(),
classDescriptor
.
getScopeForMemberResolution
(),
classDescriptor
);
resolveFunctionAndPropertyHeaders
(
jetClass
.
getDeclarations
(),
classDescriptor
.
getScopeForMemberResolution
(),
classDescriptor
);
processPrimaryConstructor
(
classDescriptor
,
jetClass
);
//
processPrimaryConstructor(classDescriptor, jetClass);
for
(
JetConstructor
jetConstructor
:
jetClass
.
getSecondaryConstructors
())
{
//
for (JetConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
processSecondaryConstructor
(
classDescriptor
,
jetConstructor
);
//
processSecondaryConstructor(classDescriptor, jetConstructor);
}
//
}
}
}
for
(
Map
.
Entry
<
JetObjectDeclaration
,
MutableClassDescriptor
>
entry
:
objects
.
entrySet
())
{
for
(
Map
.
Entry
<
JetObjectDeclaration
,
MutableClassDescriptor
>
entry
:
objects
.
entrySet
())
{
JetObjectDeclaration
object
=
entry
.
getKey
();
JetObjectDeclaration
object
=
entry
.
getKey
();
...
...
idea/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
浏览文件 @
6158c306
...
@@ -98,49 +98,54 @@ public class CallResolver {
...
@@ -98,49 +98,54 @@ public class CallResolver {
prioritizedTasks
=
FUNCTION_TASK_PRIORITIZER
.
computePrioritizedTasks
(
scope
,
receiverType
,
call
,
name
);
prioritizedTasks
=
FUNCTION_TASK_PRIORITIZER
.
computePrioritizedTasks
(
scope
,
receiverType
,
call
,
name
);
}
}
else
if
(
calleeExpression
instanceof
JetConstructorCalleeExpression
)
{
else
{
assert
receiverType
==
null
;
JetValueArgumentList
valueArgumentList
=
call
.
getValueArgumentList
();
ASTNode
reportAbsenceOn
=
valueArgumentList
==
null
?
call
.
getNode
()
:
valueArgumentList
.
getNode
();
if
(
calleeExpression
instanceof
JetConstructorCalleeExpression
)
{
assert
receiverType
==
null
;
prioritizedTasks
=
Lists
.
newArrayList
();
prioritizedTasks
=
Lists
.
newArrayList
();
JetConstructorCalleeExpression
expression
=
(
JetConstructorCalleeExpression
)
calleeExpression
;
JetConstructorCalleeExpression
expression
=
(
JetConstructorCalleeExpression
)
calleeExpression
;
functionReference
=
expression
.
getConstructorReferenceExpression
();
functionReference
=
expression
.
getConstructorReferenceExpression
();
if
(
functionReference
==
null
)
{
if
(
functionReference
==
null
)
{
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
// No type there
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
// No type there
}
JetTypeReference
typeReference
=
expression
.
getTypeReference
();
assert
typeReference
!=
null
;
JetType
constructedType
=
new
TypeResolver
(
semanticServices
,
trace
,
true
).
resolveType
(
scope
,
typeReference
);
DeclarationDescriptor
declarationDescriptor
=
constructedType
.
getConstructor
().
getDeclarationDescriptor
();
if
(
declarationDescriptor
instanceof
ClassDescriptor
)
{
ClassDescriptor
classDescriptor
=
(
ClassDescriptor
)
declarationDescriptor
;
Set
<
FunctionDescriptor
>
constructors
=
classDescriptor
.
getConstructors
().
getFunctionDescriptors
();
if
(
constructors
.
isEmpty
())
{
trace
.
getErrorHandler
().
genericError
(
reportAbsenceOn
,
"This class does not have a constructor"
);
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
}
prioritizedTasks
.
add
(
new
ResolutionTask
<
FunctionDescriptor
>(
constructors
,
null
,
call
));
}
else
{
trace
.
getErrorHandler
().
genericError
(
calleeExpression
.
getNode
(),
"Not a class"
);
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
}
}
}
JetTypeReference
typeReference
=
expression
.
getTypeReference
();
else
if
(
calleeExpression
instanceof
JetThisReferenceExpression
)
{
assert
typeReference
!=
null
;
functionReference
=
(
JetThisReferenceExpression
)
calleeExpression
;
JetType
constructedType
=
new
TypeResolver
(
semanticServices
,
trace
,
true
).
resolveType
(
scope
,
typeReference
);
DeclarationDescriptor
containingDeclaration
=
scope
.
getContainingDeclaration
();
DeclarationDescriptor
declarationDescriptor
=
constructedType
.
getConstructor
().
getDeclarationDescriptor
();
assert
containingDeclaration
instanceof
ClassDescriptor
;
if
(
declarationDescriptor
instanceof
ClassDescriptor
)
{
ClassDescriptor
classDescriptor
=
(
ClassDescriptor
)
containingDeclaration
;
ClassDescriptor
classDescriptor
=
(
ClassDescriptor
)
declarationDescriptor
;
Set
<
FunctionDescriptor
>
constructors
=
classDescriptor
.
getConstructors
().
getFunctionDescriptors
();
Set
<
FunctionDescriptor
>
constructors
=
classDescriptor
.
getConstructors
().
getFunctionDescriptors
();
if
(
constructors
.
isEmpty
())
{
if
(
constructors
.
isEmpty
())
{
trace
.
getErrorHandler
().
genericError
(
call
.
getValueArgumentList
().
getNode
()
,
"This class does not have a constructor"
);
trace
.
getErrorHandler
().
genericError
(
reportAbsenceOn
,
"This class does not have a constructor"
);
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
}
}
prioritizedTasks
.
add
(
new
ResolutionTask
<
FunctionDescriptor
>(
constructors
,
null
,
call
));
prioritizedTasks
=
Collections
.
singletonList
(
new
ResolutionTask
<
FunctionDescriptor
>(
constructors
,
null
,
call
));
}
}
else
{
else
{
trace
.
getErrorHandler
().
genericError
(
calleeExpression
.
getNode
(),
"Not a class"
);
throw
new
UnsupportedOperationException
(
"Type argument inference not implemented for "
+
call
.
getText
());
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
}
}
}
else
if
(
calleeExpression
instanceof
JetThisReferenceExpression
)
{
functionReference
=
(
JetThisReferenceExpression
)
calleeExpression
;
DeclarationDescriptor
containingDeclaration
=
scope
.
getContainingDeclaration
();
assert
containingDeclaration
instanceof
ClassDescriptor
;
ClassDescriptor
classDescriptor
=
(
ClassDescriptor
)
containingDeclaration
;
Set
<
FunctionDescriptor
>
constructors
=
classDescriptor
.
getConstructors
().
getFunctionDescriptors
();
if
(
constructors
.
isEmpty
())
{
trace
.
getErrorHandler
().
genericError
(
call
.
getValueArgumentList
().
getNode
(),
"This class does not have a constructor"
);
return
checkArgumentTypesAndFail
(
trace
,
scope
,
call
);
}
prioritizedTasks
=
Collections
.
singletonList
(
new
ResolutionTask
<
FunctionDescriptor
>(
constructors
,
null
,
call
));
}
else
{
throw
new
UnsupportedOperationException
(
"Type argument inference not implemented for "
+
call
.
getText
());
}
}
return
resolveCallToDescriptor
(
trace
,
scope
,
call
,
call
.
getNode
(),
expectedType
,
prioritizedTasks
,
functionReference
);
return
resolveCallToDescriptor
(
trace
,
scope
,
call
,
call
.
getNode
(),
expectedType
,
prioritizedTasks
,
functionReference
);
...
...
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
浏览文件 @
6158c306
...
@@ -170,6 +170,10 @@ public class JetTypeInferrer {
...
@@ -170,6 +170,10 @@ public class JetTypeInferrer {
return
new
Services
(
trace
);
return
new
Services
(
trace
);
}
}
public
CallResolver
getCallResolver
()
{
return
callResolver
;
}
public
class
Services
{
public
class
Services
{
private
final
BindingTrace
trace
;
private
final
BindingTrace
trace
;
private
final
CompileTimeConstantResolver
compileTimeConstantResolver
;
private
final
CompileTimeConstantResolver
compileTimeConstantResolver
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录