Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
d58e988c
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,发现更多精彩内容 >>
提交
d58e988c
编写于
5月 03, 2012
作者:
A
Alex Tkachman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
incorporating Sveta's patch on VariableAsFunctionResolvedCall
上级
6626086a
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
102 addition
and
136 deletion
+102
-136
compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java
...backend/src/org/jetbrains/jet/codegen/CallableMethod.java
+1
-1
compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
...kend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
+29
-13
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.java
...ns/jet/lang/descriptors/VariableAsFunctionDescriptor.java
+0
-58
compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java
...c/org/jetbrains/jet/lang/resolve/BindingContextUtils.java
+6
-9
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionTask.java
.../org/jetbrains/jet/lang/resolve/calls/ResolutionTask.java
+5
-1
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/VariableAsFunctionResolvedCall.java
...et/lang/resolve/calls/VariableAsFunctionResolvedCall.java
+7
-13
compiler/testData/codegen/extensionFunctions/nested2.kt
compiler/testData/codegen/extensionFunctions/nested2.kt
+8
-0
compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java
...sts/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java
+5
-0
compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java
compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java
+14
-1
compiler/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java
.../tests/org/jetbrains/jet/resolve/ExpectedResolveData.java
+0
-4
idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
.../jet/plugin/highlighter/FunctionsHighlightingVisitor.java
+1
-1
idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java
...jet/plugin/highlighter/PropertiesHighlightingVisitor.java
+0
-3
idea/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java
.../jet/plugin/highlighter/VariablesHighlightingVisitor.java
+0
-5
js/js.translator/src/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.java
...ns/k2js/translate/reference/CallExpressionTranslator.java
+4
-4
js/js.translator/src/org/jetbrains/k2js/translate/reference/CallParametersResolver.java
...ains/k2js/translate/reference/CallParametersResolver.java
+6
-6
js/js.translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java
...rg/jetbrains/k2js/translate/reference/CallTranslator.java
+4
-5
js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
.../src/org/jetbrains/k2js/translate/utils/BindingUtils.java
+4
-4
js/js.translator/src/org/jetbrains/k2js/translate/utils/JsDescriptorUtils.java
...org/jetbrains/k2js/translate/utils/JsDescriptorUtils.java
+8
-8
未找到文件。
compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java
浏览文件 @
d58e988c
...
...
@@ -79,7 +79,7 @@ public class CallableMethod implements Callable {
}
public
void
setNeedsReceiver
(
@Nullable
CallableDescriptor
receiverClass
)
{
this
.
receiverFunction
=
receiverClass
;
this
.
receiverFunction
=
receiverClass
.
getOriginal
()
;
}
public
JetType
getThisType
()
{
...
...
compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
浏览文件 @
d58e988c
...
...
@@ -964,13 +964,17 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
descriptor
=
bindingContext
.
get
(
BindingContext
.
REFERENCE_TARGET
,
expression
);
}
else
{
if
(
resolvedCall
instanceof
VariableAsFunctionResolvedCall
)
{
VariableAsFunctionResolvedCall
call
=
(
VariableAsFunctionResolvedCall
)
resolvedCall
;
resolvedCall
=
call
.
getVariableCall
();
}
receiver
=
StackValue
.
receiver
(
resolvedCall
,
receiver
,
this
,
null
,
state
);
descriptor
=
resolvedCall
.
getResultingDescriptor
();
}
if
(
descriptor
instanceof
VariableAsFunctionDescriptor
)
{
descriptor
=
((
VariableAsFunctionDescriptor
)
descriptor
).
getVariableDescriptor
();
}
//
if (descriptor instanceof VariableAsFunctionDescriptor) {
//
descriptor = ((VariableAsFunctionDescriptor) descriptor).getVariableDescriptor();
//
}
final
IntrinsicMethod
intrinsic
=
state
.
getInjector
().
getIntrinsics
().
getIntrinsic
(
descriptor
);
if
(
intrinsic
!=
null
)
{
...
...
@@ -1255,14 +1259,24 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
else
if
(
funDescriptor
instanceof
FunctionDescriptor
)
{
final
FunctionDescriptor
fd
=
(
FunctionDescriptor
)
funDescriptor
;
return
invokeFunction
(
expression
,
fd
,
receiver
);
if
(
resolvedCall
instanceof
VariableAsFunctionResolvedCall
)
{
VariableAsFunctionResolvedCall
call
=
(
VariableAsFunctionResolvedCall
)
resolvedCall
;
ResolvedCallWithTrace
<
FunctionDescriptor
>
functionCall
=
call
.
getFunctionCall
();
return
invokeFunction
(
expression
,
functionCall
.
getResultingDescriptor
(),
receiver
,
functionCall
);
}
else
{
return
invokeFunction
(
expression
,
fd
,
receiver
,
resolvedCall
);
}
}
else
{
throw
new
UnsupportedOperationException
(
"unknown type of callee descriptor: "
+
funDescriptor
);
}
}
private
StackValue
invokeFunction
(
JetCallExpression
expression
,
DeclarationDescriptor
fd
,
StackValue
receiver
)
{
private
StackValue
invokeFunction
(
JetCallExpression
expression
,
DeclarationDescriptor
fd
,
StackValue
receiver
,
ResolvedCall
<?
extends
CallableDescriptor
>
resolvedCall
)
{
boolean
superCall
=
false
;
if
(
expression
.
getParent
()
instanceof
JetQualifiedExpression
)
{
final
JetExpression
receiverExpression
=
((
JetQualifiedExpression
)
expression
.
getParent
()).
getReceiverExpression
();
...
...
@@ -1295,8 +1309,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
return
returnValueAsStackValue
((
FunctionDescriptor
)
fd
,
callReturnType
);
}
else
{
ResolvedCall
<?
extends
CallableDescriptor
>
resolvedCall
=
bindingContext
.
get
(
BindingContext
.
RESOLVED_CALL
,
expression
.
getCalleeExpression
());
assert
resolvedCall
!=
null
;
receiver
=
StackValue
.
receiver
(
resolvedCall
,
receiver
,
this
,
null
,
state
);
IntrinsicMethod
intrinsic
=
(
IntrinsicMethod
)
callable
;
...
...
@@ -1324,11 +1336,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
CallableMethod
callableMethod
;
if
(
fd
instanceof
VariableAsFunctionDescriptor
)
{
assert
!
superCall
;
callableMethod
=
ClosureCodegen
.
asCallableMethod
((
FunctionDescriptor
)
fd
);
}
else
if
(
fd
instanceof
ExpressionAsFunctionDescriptor
||
(
fd
instanceof
SimpleFunctionDescriptor
&&
fd
.
getContainingDeclaration
()
instanceof
FunctionDescriptor
))
{
//
if (fd instanceof VariableAsFunctionDescriptor) {
//
assert !superCall;
//
callableMethod = ClosureCodegen.asCallableMethod((FunctionDescriptor) fd);
//
}
if
(
fd
instanceof
ExpressionAsFunctionDescriptor
||
(
fd
instanceof
SimpleFunctionDescriptor
&&
fd
.
getContainingDeclaration
()
instanceof
FunctionDescriptor
))
{
SimpleFunctionDescriptor
invoke
=
CodegenUtil
.
createInvoke
((
FunctionDescriptor
)
fd
);
callableMethod
=
ClosureCodegen
.
asCallableMethod
(
invoke
);
}
...
...
@@ -1351,6 +1363,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
ResolvedCall
<?
extends
CallableDescriptor
>
resolvedCall
=
bindingContext
.
get
(
BindingContext
.
RESOLVED_CALL
,
expression
.
getCalleeExpression
());
assert
resolvedCall
!=
null
;
if
(
resolvedCall
instanceof
VariableAsFunctionResolvedCall
)
{
resolvedCall
=
((
VariableAsFunctionResolvedCall
)
resolvedCall
).
getFunctionCall
();
}
if
(!(
resolvedCall
.
getResultingDescriptor
()
instanceof
ConstructorDescriptor
))
{
// otherwise already
receiver
=
StackValue
.
receiver
(
resolvedCall
,
receiver
,
this
,
callableMethod
,
state
);
receiver
.
put
(
receiver
.
type
,
v
);
...
...
@@ -1397,7 +1413,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
else
if
(
descriptor
instanceof
ExpressionReceiver
)
{
ExpressionReceiver
expressionReceiver
=
(
ExpressionReceiver
)
descriptor
;
JetExpression
expr
=
expressionReceiver
.
getExpression
();
Type
exprType
=
expressionType
(
expr
);
Type
exprType
=
asmType
(
expressionReceiver
.
getType
()
);
gen
(
expr
,
exprType
);
if
(
type
!=
null
)
StackValue
.
onStack
(
exprType
).
put
(
type
,
v
);
...
...
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.java
已删除
100644 → 0
浏览文件 @
6626086a
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.jet.lang.descriptors
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
;
import
org.jetbrains.jet.lang.types.JetType
;
import
java.util.Collections
;
/**
* @author abreslav
*/
public
class
VariableAsFunctionDescriptor
extends
FunctionDescriptorImpl
{
public
static
VariableAsFunctionDescriptor
create
(
@NotNull
VariableDescriptor
variableDescriptor
)
{
JetType
outType
=
variableDescriptor
.
getType
();
assert
outType
!=
null
;
VariableAsFunctionDescriptor
result
=
new
VariableAsFunctionDescriptor
(
variableDescriptor
);
FunctionDescriptorUtil
.
initializeFromFunctionType
(
result
,
outType
,
variableDescriptor
.
getExpectedThisObject
());
return
result
;
}
private
final
VariableDescriptor
variableDescriptor
;
private
VariableAsFunctionDescriptor
(
VariableDescriptor
variableDescriptor
)
{
super
(
variableDescriptor
.
getContainingDeclaration
(),
Collections
.<
AnnotationDescriptor
>
emptyList
(),
variableDescriptor
.
getName
(),
Kind
.
DECLARATION
);
this
.
variableDescriptor
=
variableDescriptor
;
}
public
VariableDescriptor
getVariableDescriptor
()
{
return
variableDescriptor
;
}
@NotNull
@Override
public
VariableAsFunctionDescriptor
copy
(
DeclarationDescriptor
newOwner
,
boolean
makeNonAbstract
,
Kind
kind
,
boolean
copyOverrides
)
{
throw
new
UnsupportedOperationException
(
"Should not be copied for overriding"
);
}
@Override
protected
FunctionDescriptorImpl
createSubstitutedCopy
(
DeclarationDescriptor
newOwner
,
boolean
preserveOriginal
,
Kind
kind
)
{
throw
new
IllegalStateException
();
}
}
compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java
浏览文件 @
d58e988c
...
...
@@ -49,12 +49,12 @@ public class BindingContextUtils {
throw
new
IllegalStateException
(
"non-declaration descriptors should be filtered out earler: "
+
callable
);
}
}
if
(
declarationDescriptor
instanceof
VariableAsFunctionDescriptor
)
{
VariableAsFunctionDescriptor
descriptor
=
(
VariableAsFunctionDescriptor
)
declarationDescriptor
;
if
(
descriptor
.
getOriginal
()
!=
descriptor
)
{
throw
new
IllegalStateException
(
"original should be resolved earlier: "
+
descriptor
);
}
}
//
if (declarationDescriptor instanceof VariableAsFunctionDescriptor) {
//
VariableAsFunctionDescriptor descriptor = (VariableAsFunctionDescriptor) declarationDescriptor;
//
if (descriptor.getOriginal() != descriptor) {
//
throw new IllegalStateException("original should be resolved earlier: " + descriptor);
//
}
//
}
return
declarationDescriptor
.
getOriginal
();
}
};
...
...
@@ -118,9 +118,6 @@ public class BindingContextUtils {
if
(
descriptor
instanceof
VariableDescriptor
)
{
return
(
VariableDescriptor
)
descriptor
;
}
if
(
descriptor
instanceof
VariableAsFunctionDescriptor
)
{
return
((
VariableAsFunctionDescriptor
)
descriptor
).
getVariableDescriptor
();
}
return
null
;
}
...
...
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionTask.java
浏览文件 @
d58e988c
...
...
@@ -99,7 +99,11 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
public
final
TracingStrategy
tracing
=
new
TracingStrategy
()
{
@Override
public
<
D
extends
CallableDescriptor
>
void
bindResolvedCall
(
@NotNull
BindingTrace
trace
,
@NotNull
ResolvedCallWithTrace
<
D
>
resolvedCall
)
{
trace
.
record
(
REFERENCE_TARGET
,
reference
,
resolvedCall
.
getResultingDescriptor
());
CallableDescriptor
descriptor
=
resolvedCall
.
getResultingDescriptor
();
if
(
resolvedCall
instanceof
VariableAsFunctionResolvedCall
)
{
descriptor
=
((
VariableAsFunctionResolvedCall
)
resolvedCall
).
getVariableCall
().
getResultingDescriptor
();
}
trace
.
record
(
REFERENCE_TARGET
,
reference
,
descriptor
);
trace
.
record
(
RESOLVED_CALL
,
call
.
getCalleeExpression
(),
resolvedCall
);
}
...
...
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/VariableAsFunctionResolvedCall.java
浏览文件 @
d58e988c
...
...
@@ -17,11 +17,13 @@
package
org.jetbrains.jet.lang.resolve.calls
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.descriptors.*
;
import
org.jetbrains.jet.lang.descriptors.FunctionDescriptor
;
import
org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor
;
import
org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
;
import
org.jetbrains.jet.lang.descriptors.VariableDescriptor
;
import
org.jetbrains.jet.lang.resolve.TemporaryBindingTrace
;
import
org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
;
import
org.jetbrains.jet.lang.types.JetType
;
import
org.jetbrains.jet.lang.types.lang.JetStandardClasses
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -32,18 +34,11 @@ import java.util.Map;
public
class
VariableAsFunctionResolvedCall
implements
ResolvedCallWithTrace
<
FunctionDescriptor
>
{
private
final
ResolvedCallWithTrace
<
FunctionDescriptor
>
functionCall
;
private
final
ResolvedCallWithTrace
<
VariableDescriptor
>
variableCall
;
private
final
VariableAsFunctionDescriptor
variableAsFunctionDescriptor
;
public
VariableAsFunctionResolvedCall
(
@NotNull
ResolvedCallWithTrace
<
FunctionDescriptor
>
functionCall
,
@NotNull
ResolvedCallWithTrace
<
VariableDescriptor
>
variableCall
)
{
this
.
functionCall
=
functionCall
;
this
.
variableCall
=
variableCall
;
if
(
JetStandardClasses
.
isFunctionType
(
variableCall
.
getResultingDescriptor
().
getType
()))
{
variableAsFunctionDescriptor
=
VariableAsFunctionDescriptor
.
create
(
variableCall
.
getResultingDescriptor
());
}
else
{
variableAsFunctionDescriptor
=
null
;
}
}
public
ResolvedCallWithTrace
<
FunctionDescriptor
>
getFunctionCall
()
{
...
...
@@ -57,20 +52,19 @@ public class VariableAsFunctionResolvedCall implements ResolvedCallWithTrace<Fun
@NotNull
@Override
public
FunctionDescriptor
getCandidateDescriptor
()
{
return
variableAsFunctionDescriptor
!=
null
?
variableAsFunctionDescriptor
:
functionCall
.
getResultingDescriptor
();
return
functionCall
.
getResultingDescriptor
();
}
@NotNull
@Override
public
FunctionDescriptor
getResultingDescriptor
()
{
return
variableAsFunctionDescriptor
!=
null
?
variableAsFunctionDescriptor
:
functionCall
.
getResultingDescriptor
();
return
functionCall
.
getResultingDescriptor
();
}
@NotNull
@Override
public
ReceiverDescriptor
getReceiverArgument
()
{
ReceiverDescriptor
receiverArgument
=
variableCall
.
getReceiverArgument
();
return
receiverArgument
.
exists
()
?
receiverArgument
:
functionCall
.
getReceiverArgument
();
return
variableCall
.
getReceiverArgument
();
}
@NotNull
...
...
compiler/testData/codegen/extensionFunctions/nested2.kt
0 → 100644
浏览文件 @
d58e988c
fun
box
()
:
String
{
val
y
=
12
val
op
=
{
(
x
:
Int
)
->
(
x
+
y
).
toString
()
}
val
op2
:
Int
.(
Int
)
->
String
=
{
op
(
this
+
it
)
}
return
if
(
"27"
==
5
.
op2
(
10
))
"OK"
else
"fail"
}
compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java
浏览文件 @
d58e988c
...
...
@@ -71,4 +71,9 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
createEnvironmentWithFullJdk
();
blackBoxFile
(
"regressions/kt865.jet"
);
}
public
void
testKtNested2
()
throws
Exception
{
createEnvironmentWithMockJdk
(
CompilerSpecialMode
.
BUILTINS
);
blackBoxFile
(
"extensionFunctions/nested2.kt"
);
}
}
compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java
浏览文件 @
d58e988c
...
...
@@ -20,6 +20,7 @@ import com.intellij.openapi.vfs.local.CoreLocalFileSystem;
import
gnu.trove.THashSet
;
import
junit.framework.Test
;
import
junit.framework.TestCase
;
import
junit.framework.TestResult
;
import
junit.framework.TestSuite
;
import
org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime
;
import
org.jetbrains.jet.cli.jvm.compiler.K2JVMCompileEnvironmentConfiguration
;
...
...
@@ -126,6 +127,19 @@ public class TestlibTest extends CodegenTestCase {
suite
.
addTestSuite
(
aClass
);
}
}
catch
(
final
VerifyError
e
)
{
suite
.
addTest
(
new
TestCase
(
aClass
.
getName
())
{
@Override
public
int
countTestCases
()
{
return
1
;
}
@Override
public
void
run
(
TestResult
result
)
{
result
.
addError
(
this
,
new
RuntimeException
(
e
));
}
});
}
catch
(
NoSuchMethodException
e
)
{
}
}
...
...
@@ -141,7 +155,6 @@ public class TestlibTest extends CodegenTestCase {
}
return
suite
;
}
catch
(
RuntimeException
e
)
{
throw
e
;
}
catch
(
Throwable
e
)
{
...
...
compiler/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java
浏览文件 @
d58e988c
...
...
@@ -279,10 +279,6 @@ public abstract class ExpectedResolveData {
DeclarationDescriptor
actualDescriptor
=
bindingContext
.
get
(
REFERENCE_TARGET
,
reference
);
if
(
actualDescriptor
instanceof
VariableAsFunctionDescriptor
)
{
VariableAsFunctionDescriptor
descriptor
=
(
VariableAsFunctionDescriptor
)
actualDescriptor
;
actualDescriptor
=
descriptor
.
getVariableDescriptor
();
}
assertEquals
(
"Reference `"
+
name
+
"`"
+
renderReferenceInContext
(
reference
)
+
" is resolved into "
+
actualName
+
"."
,
...
...
idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
浏览文件 @
d58e988c
...
...
@@ -72,7 +72,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
if
(
calleeDescriptor
instanceof
ConstructorDescriptor
)
{
JetPsiChecker
.
highlightName
(
holder
,
callee
,
JetHighlightingColors
.
CONSTRUCTOR_CALL
);
}
else
if
(
calleeDescriptor
instanceof
FunctionDescriptor
&&
!(
calleeDescriptor
instanceof
VariableAsFunctionDescriptor
)
)
{
else
if
(
calleeDescriptor
instanceof
FunctionDescriptor
)
{
FunctionDescriptor
fun
=
(
FunctionDescriptor
)
calleeDescriptor
;
JetPsiChecker
.
highlightName
(
holder
,
callee
,
JetHighlightingColors
.
FUNCTION_CALL
);
if
(
fun
.
getContainingDeclaration
()
instanceof
NamespaceDescriptor
)
{
...
...
idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java
浏览文件 @
d58e988c
...
...
@@ -36,9 +36,6 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
return
;
}
DeclarationDescriptor
target
=
bindingContext
.
get
(
BindingContext
.
REFERENCE_TARGET
,
expression
);
if
(
target
instanceof
VariableAsFunctionDescriptor
)
{
target
=
((
VariableAsFunctionDescriptor
)
target
).
getVariableDescriptor
();
}
if
(!(
target
instanceof
PropertyDescriptor
))
{
return
;
}
...
...
idea/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java
浏览文件 @
d58e988c
...
...
@@ -86,11 +86,6 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
}
private
void
highlightVariable
(
@NotNull
PsiElement
elementToHighlight
,
@NotNull
DeclarationDescriptor
descriptor
)
{
if
(
descriptor
instanceof
VariableAsFunctionDescriptor
)
{
descriptor
=
((
VariableAsFunctionDescriptor
)
descriptor
).
getVariableDescriptor
();
//noinspection ConstantConditions
if
(
descriptor
==
null
)
return
;
}
if
(
descriptor
instanceof
VariableDescriptor
)
{
VariableDescriptor
variableDescriptor
=
(
VariableDescriptor
)
descriptor
;
if
(
variableDescriptor
.
isVar
())
{
...
...
js/js.translator/src/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.java
浏览文件 @
d58e988c
...
...
@@ -21,12 +21,12 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.descriptors.CallableDescriptor
;
import
org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
;
import
org.jetbrains.jet.lang.descriptors.VariableAsFunctionDescriptor
;
import
org.jetbrains.jet.lang.psi.JetCallExpression
;
import
org.jetbrains.jet.lang.psi.JetExpression
;
import
org.jetbrains.jet.lang.psi.JetSimpleNameExpression
;
import
org.jetbrains.jet.lang.resolve.calls.ExpressionAsFunctionDescriptor
;
import
org.jetbrains.jet.lang.resolve.calls.ResolvedValueArgument
;
import
org.jetbrains.jet.lang.resolve.calls.VariableAsFunctionResolvedCall
;
import
org.jetbrains.k2js.translate.context.TranslationContext
;
import
org.jetbrains.k2js.translate.general.Translation
;
import
org.jetbrains.k2js.translate.utils.AnnotationsUtils
;
...
...
@@ -78,9 +78,9 @@ public final class CallExpressionTranslator extends AbstractCallExpressionTransl
if
(
candidateDescriptor
instanceof
ExpressionAsFunctionDescriptor
)
{
return
translateExpressionAsFunction
();
}
if
(
candidateDescriptor
instanceof
VariableAsFunctionDescriptor
)
{
return
translateVariableAsFunction
();
}
//
if (candidateDescriptor instanceof VariableAsFunctionDescriptor) {
//
return translateVariableAsFunction();
//
}
return
null
;
}
...
...
js/js.translator/src/org/jetbrains/k2js/translate/reference/CallParametersResolver.java
浏览文件 @
d58e988c
...
...
@@ -81,12 +81,12 @@ public final class CallParametersResolver {
if
(!
isVariableAsFunction
(
descriptor
))
{
return
ReferenceTranslator
.
translateAsLocalNameReference
(
descriptor
,
context
);
}
VariableDescriptor
variableDescriptor
=
getVariableDescriptorForVariableAsFunction
((
VariableAsFunctionDescriptor
)
descriptor
);
if
(
variableDescriptor
instanceof
PropertyDescriptor
)
{
return
getterCall
((
PropertyDescriptor
)
variableDescriptor
);
}
return
ReferenceTranslator
.
translateAsLocalNameReference
(
variableD
escriptor
,
context
);
//
VariableDescriptor variableDescriptor =
//
getVariableDescriptorForVariableAsFunction((VariableAsFunctionDescriptor)descriptor);
//
if (variableDescriptor instanceof PropertyDescriptor) {
//
return getterCall((PropertyDescriptor)variableDescriptor);
//
}
return
ReferenceTranslator
.
translateAsLocalNameReference
(
d
escriptor
,
context
);
}
//TODO: inspect
...
...
js/js.translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java
浏览文件 @
d58e988c
...
...
@@ -26,7 +26,6 @@ import org.jetbrains.annotations.Nullable;
import
org.jetbrains.jet.lang.descriptors.CallableDescriptor
;
import
org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
;
import
org.jetbrains.jet.lang.descriptors.FunctionDescriptor
;
import
org.jetbrains.jet.lang.descriptors.VariableAsFunctionDescriptor
;
import
org.jetbrains.jet.lang.resolve.calls.ExpressionAsFunctionDescriptor
;
import
org.jetbrains.jet.lang.resolve.calls.ResolvedCall
;
import
org.jetbrains.k2js.translate.context.TranslationContext
;
...
...
@@ -95,8 +94,8 @@ public final class CallTranslator extends AbstractTranslator {
}
private
boolean
isExpressionAsFunction
()
{
return
descriptor
instanceof
ExpressionAsFunctionDescriptor
||
descriptor
instanceof
VariableAsFunctionDescriptor
;
return
descriptor
instanceof
ExpressionAsFunctionDescriptor
;
//
||
//
descriptor instanceof VariableAsFunctionDescriptor;
}
@NotNull
...
...
@@ -142,8 +141,8 @@ public final class CallTranslator extends AbstractTranslator {
}
private
boolean
isExtensionFunctionLiteral
()
{
boolean
isLiteral
=
descriptor
instanceof
VariableAsFunctionDescriptor
||
descriptor
instanceof
ExpressionAsFunctionDescriptor
;
boolean
isLiteral
=
//descriptor instanceof VariableAsFunctionDescriptor ||
descriptor
instanceof
ExpressionAsFunctionDescriptor
;
return
isExtensionFunction
()
&&
isLiteral
;
}
...
...
js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
浏览文件 @
d58e988c
...
...
@@ -194,10 +194,10 @@ public final class BindingUtils {
public
static
DeclarationDescriptor
getNullableDescriptorForReferenceExpression
(
@NotNull
BindingContext
context
,
@NotNull
JetReferenceExpression
reference
)
{
DeclarationDescriptor
referencedDescriptor
=
context
.
get
(
BindingContext
.
REFERENCE_TARGET
,
reference
);
if
(
isVariableAsFunction
(
referencedDescriptor
))
{
assert
referencedDescriptor
!=
null
;
return
getVariableDescriptorForVariableAsFunction
((
VariableAsFunctionDescriptor
)
referencedDescriptor
);
}
//
if (isVariableAsFunction(referencedDescriptor)) {
//
assert referencedDescriptor != null;
//
return getVariableDescriptorForVariableAsFunction((VariableAsFunctionDescriptor)referencedDescriptor);
//
}
return
referencedDescriptor
;
}
...
...
js/js.translator/src/org/jetbrains/k2js/translate/utils/JsDescriptorUtils.java
浏览文件 @
d58e988c
...
...
@@ -126,17 +126,17 @@ public final class JsDescriptorUtils {
return
(
ClassDescriptor
)
superClassDescriptor
;
}
@NotNull
public
static
VariableDescriptor
getVariableDescriptorForVariableAsFunction
(
@NotNull
VariableAsFunctionDescriptor
descriptor
)
{
VariableDescriptor
functionVariable
=
descriptor
.
getVariableDescriptor
();
assert
functionVariable
!=
null
;
return
functionVariable
;
}
//
@NotNull
//
public static VariableDescriptor getVariableDescriptorForVariableAsFunction
//
(@NotNull VariableAsFunctionDescriptor descriptor) {
//
VariableDescriptor functionVariable = descriptor.getVariableDescriptor();
//
assert functionVariable != null;
//
return functionVariable;
//
}
public
static
boolean
isVariableAsFunction
(
@Nullable
DeclarationDescriptor
referencedDescriptor
)
{
return
referencedDescriptor
instanceof
VariableAsFunctionDescriptor
;
return
false
;
//
referencedDescriptor instanceof VariableAsFunctionDescriptor;
}
@NotNull
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录