Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
fd7abde1
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,发现更多精彩内容 >>
提交
fd7abde1
编写于
3月 17, 2011
作者:
A
Andrey Breslav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unary + and - for numbers
上级
28e16cc2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
8 deletion
+36
-8
idea/src/jet/lang/Library.jet
idea/src/jet/lang/Library.jet
+14
-0
idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
.../org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
+1
-1
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
+15
-5
idea/testData/resolve/ResolveOfInfixExpressions.jet
idea/testData/resolve/ResolveOfInfixExpressions.jet
+6
-2
未找到文件。
idea/src/jet/lang/Library.jet
浏览文件 @
fd7abde1
...
...
@@ -104,6 +104,8 @@ class Double : Number, Comparable<Double> {
fun inc() : Double
fun dec() : Double
fun plus() : Double
fun minus() : Double
}
class Float : Number, Comparable<Float> {
...
...
@@ -165,6 +167,8 @@ class Float : Number, Comparable<Float> {
fun inc() : Float
fun dec() : Float
fun plus() : Float
fun minus() : Float
}
class Long : Number, Comparable<Long> {
...
...
@@ -226,6 +230,8 @@ class Long : Number, Comparable<Long> {
fun inc() : Long
fun dec() : Long
fun plus() : Long
fun minus() : Long
}
class Int : Number, Comparable<Int> {
...
...
@@ -287,6 +293,8 @@ class Int : Number, Comparable<Int> {
fun inc() : Int
fun dec() : Int
fun plus() : Int
fun minus() : Int
}
class Char : Number, Comparable<Char> {
...
...
@@ -348,6 +356,8 @@ class Char : Number, Comparable<Char> {
fun inc() : Char
fun dec() : Char
fun plus() : Int
fun minus() : Int
}
class Short : Number, Comparable<Char> {
...
...
@@ -409,6 +419,8 @@ class Short : Number, Comparable<Char> {
fun inc() : Short
fun dec() : Short
fun plus() : Int
fun minus() : Int
}
class Byte : Number, Comparable<Char> {
...
...
@@ -470,4 +482,6 @@ class Byte : Number, Comparable<Char> {
fun inc() : Byte
fun dec() : Byte
fun plus() : Int
fun minus() : Int
}
\ No newline at end of file
idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
浏览文件 @
fd7abde1
...
...
@@ -1358,7 +1358,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* "new" constructorInvocation // identical to new
n
unctionCall
* "new" constructorInvocation // identical to new
f
unctionCall
*
* constructorInvocation
* : userType valueArguments
...
...
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
浏览文件 @
fd7abde1
...
...
@@ -653,16 +653,26 @@ public class JetTypeInferrer {
@Override
public
void
visitUnaryExpression
(
JetUnaryExpression
expression
)
{
JetSimpleNameExpression
operationSign
=
expression
.
getOperationSign
();
String
name
=
unaryOperationNames
.
get
(
operationSign
.
getReferencedNameElementType
());
IElementType
operationType
=
operationSign
.
getReferencedNameElementType
();
String
name
=
unaryOperationNames
.
get
(
operationType
);
if
(
name
==
null
)
{
semanticServices
.
getErrorHandler
().
genericError
(
operationSign
.
getNode
(),
"Unknown unary operation"
);
}
else
{
JetType
t
ype
=
getType
(
scope
,
expression
.
getBaseExpression
(),
false
);
if
(
t
ype
!=
null
)
{
FunctionDescriptor
functionDescriptor
=
lookupFunction
(
scope
,
expression
.
getOperationSign
(),
name
,
t
ype
,
Collections
.<
JetType
>
emptyList
(),
true
);
JetType
receiverT
ype
=
getType
(
scope
,
expression
.
getBaseExpression
(),
false
);
if
(
receiverT
ype
!=
null
)
{
FunctionDescriptor
functionDescriptor
=
lookupFunction
(
scope
,
expression
.
getOperationSign
(),
name
,
receiverT
ype
,
Collections
.<
JetType
>
emptyList
(),
true
);
if
(
functionDescriptor
!=
null
)
{
result
=
functionDescriptor
.
getUnsubstitutedReturnType
();
JetType
returnType
=
functionDescriptor
.
getUnsubstitutedReturnType
();
if
(
operationType
==
JetTokens
.
PLUSPLUS
||
operationType
==
JetTokens
.
MINUSMINUS
)
{
if
(!
semanticServices
.
getTypeChecker
().
isSubtypeOf
(
returnType
,
receiverType
))
{
semanticServices
.
getErrorHandler
().
genericError
(
operationSign
.
getNode
(),
name
+
" must return "
+
receiverType
+
" but returns "
+
returnType
);
}
// TODO : Maybe returnType?
result
=
receiverType
;
}
else
{
result
=
returnType
;
}
}
}
}
...
...
idea/testData/resolve/ResolveOfInfixExpressions.jet
浏览文件 @
fd7abde1
...
...
@@ -44,8 +44,10 @@ import util.*
~Bar~class Bar : Foo {
~not~fun not() : String {}
~inc~fun inc() : Unit
~dec~fun dec() : Unit
~inc~fun inc() : Bar
~dec~fun dec() : Bar
~-~fun minus() : Bar
~+~fun plus() : Bar
}
fun <T> tt(t : T) : T {
...
...
@@ -68,6 +70,8 @@ fun <T> tt(t : T) : T {
`dec`--y
y`dec`--
y `+=`+= 1
`+`+y
`-`-y
1 `std::Int.compareTo(Double)`> 2.0
1 `std::Int.compareTo(Double)`< 2.0
1 `std::Int.compareTo(Double)`>= 2.0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录