Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
90849a67
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,发现更多精彩内容 >>
提交
90849a67
编写于
10月 08, 2015
作者:
A
Alexey Tsvetkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prohibit annotations, modifiers and default values for parameters in function type
#KT-7619 fixed
上级
27a1a17c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
215 addition
and
3 deletion
+215
-3
compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt
...frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt
+28
-1
compiler/testData/diagnostics/tests/DefaultValueForParameterInFunctionType.kt
...agnostics/tests/DefaultValueForParameterInFunctionType.kt
+20
-0
compiler/testData/diagnostics/tests/DefaultValueForParameterInFunctionType.txt
...gnostics/tests/DefaultValueForParameterInFunctionType.txt
+16
-0
compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.kt
.../tests/annotations/annotationOnParameterInFunctionType.kt
+29
-0
compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.txt
...tests/annotations/annotationOnParameterInFunctionType.txt
+32
-0
compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/typeReferenceError.kt
...pleteCode/diagnosticWithSyntaxError/typeReferenceError.kt
+1
-2
compiler/testData/diagnostics/tests/modifiers/modifierOnParameterInFunctionType.kt
...tics/tests/modifiers/modifierOnParameterInFunctionType.kt
+52
-0
compiler/testData/diagnostics/tests/modifiers/modifierOnParameterInFunctionType.txt
...ics/tests/modifiers/modifierOnParameterInFunctionType.txt
+19
-0
compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java
...etbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java
+18
-0
未找到文件。
compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt
浏览文件 @
90849a67
...
...
@@ -24,13 +24,14 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import
org.jetbrains.kotlin.descriptors.annotations.Annotations
import
org.jetbrains.kotlin.diagnostics.Errors
import
org.jetbrains.kotlin.diagnostics.Errors.*
import
org.jetbrains.kotlin.lexer.JetTokens
import
org.jetbrains.kotlin.psi.*
import
org.jetbrains.kotlin.psi.codeFragmentUtil.debugTypeInfo
import
org.jetbrains.kotlin.psi.debugText.getDebugText
import
org.jetbrains.kotlin.resolve.PossiblyBareType.type
import
org.jetbrains.kotlin.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider
import
org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallableDescriptors
import
org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope
import
org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallableDescriptors
import
org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
import
org.jetbrains.kotlin.resolve.lazy.LazyEntity
import
org.jetbrains.kotlin.resolve.scopes.JetScope
...
...
@@ -239,6 +240,7 @@ public class TypeResolver(
val
receiverTypeRef
=
type
.
getReceiverTypeReference
()
val
receiverType
=
if
(
receiverTypeRef
==
null
)
null
else
resolveType
(
c
.
noBareTypes
(),
receiverTypeRef
)
type
.
parameters
.
forEach
{
checkParameterInFunctionType
(
it
)
}
val
parameterTypes
=
type
.
getParameters
().
map
{
resolveType
(
c
.
noBareTypes
(),
it
.
getTypeReference
()
!!
)
}
val
returnTypeRef
=
type
.
getReturnTypeReference
()
...
...
@@ -262,6 +264,31 @@ public class TypeResolver(
override
fun
visitJetElement
(
element
:
JetElement
)
{
c
.
trace
.
report
(
UNSUPPORTED
.
on
(
element
,
"Self-types are not supported yet"
))
}
private
fun
checkParameterInFunctionType
(
param
:
JetParameter
)
{
if
(
param
.
hasDefaultValue
())
{
c
.
trace
.
report
(
Errors
.
UNSUPPORTED
.
on
(
param
.
defaultValue
!!
,
"default value of parameter in function type"
))
}
if
(
param
.
nameIdentifier
!=
null
)
{
for
(
annotationEntry
in
param
.
annotationEntries
)
{
c
.
trace
.
report
(
Errors
.
UNSUPPORTED
.
on
(
annotationEntry
,
"annotation on parameter in function type"
))
}
}
val
modifierList
=
param
.
modifierList
if
(
modifierList
!=
null
)
{
JetTokens
.
MODIFIER_KEYWORDS_ARRAY
.
map
{
modifierList
.
getModifier
(
it
)
}
.
filterNotNull
()
.
forEach
{
c
.
trace
.
report
(
Errors
.
UNSUPPORTED
.
on
(
it
,
"modifier on parameter in function type"
))
}
}
param
.
valOrVarKeyword
?.
let
{
c
.
trace
.
report
(
Errors
.
UNSUPPORTED
.
on
(
it
,
"val or val on parameter in function type"
))
}
}
})
return
result
?:
type
(
ErrorUtils
.
createErrorType
(
typeElement
?.
getDebugText
()
?:
"No type element"
))
...
...
compiler/testData/diagnostics/tests/DefaultValueForParameterInFunctionType.kt
0 → 100644
浏览文件 @
90849a67
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun
f
(
x
:
Int
=
0
)
{}
val
inVal
:
(
x
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
=
{}
fun
inParam
(
fn
:
(
x
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
)
{}
fun
inParamNested
(
fn1
:
(
fn2
:
(
n
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
)->
Unit
)
{}
fun
inReturn
():
(
x
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
=
{}
class
A
:
(
x
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
{
override
fun
invoke
(
p1
:
Int
)
{
var
lambda
:
(
x
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
=
{}
}
val
prop
:
(
x
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
get
():
(
x
:
Int
=
<!
UNSUPPORTED
!>
0
<!>)->
Unit
=
{}
}
compiler/testData/diagnostics/tests/DefaultValueForParameterInFunctionType.txt
0 → 100644
浏览文件 @
90849a67
package
public val inVal: (kotlin.Int) -> kotlin.Unit
public fun f(/*0*/ x: kotlin.Int = ...): kotlin.Unit
public fun inParam(/*0*/ fn: (kotlin.Int) -> kotlin.Unit): kotlin.Unit
public fun inParamNested(/*0*/ fn1: ((kotlin.Int) -> kotlin.Unit) -> kotlin.Unit): kotlin.Unit
public fun inReturn(): (kotlin.Int) -> kotlin.Unit
public final class A : (kotlin.Int) -> kotlin.Unit {
public constructor A()
public final val prop: (kotlin.Int) -> kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ fun invoke(/*0*/ p1: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.kt
0 → 100644
浏览文件 @
90849a67
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
annotation
class
Ann
fun
f
(
@Ann
x
:
Int
)
{}
val
inVal
:
(<!
UNSUPPORTED
!>
@Ann
<!>
x
:
Int
)->
Unit
=
{}
fun
inParam
(
fn
:
(<!
UNSUPPORTED
!>
@Ann
<!>
x
:
Int
)->
Unit
)
{}
fun
inParamNested
(
fn1
:
(
fn2
:
(<!
UNSUPPORTED
!>
@Ann
<!>
n
:
Int
)->
Unit
)->
Unit
)
{}
fun
inReturn
():
(<!
UNSUPPORTED
!>
@Ann
<!>
x
:
Int
)->
Unit
=
{}
class
A
:
(
@
<!
DEBUG_INFO_MISSING_UNRESOLVED
!>
Ann
<
!
>
Int
)->
Unit
{
override
fun
invoke
(
p1
:
Int
)
{
var
lambda
:
(<!
UNSUPPORTED
!>
@Ann
<!>
x
:
Int
)->
Unit
=
{}
}
val
prop
:
(<!
UNSUPPORTED
!>
@Ann
<!>
x
:
Int
)->
Unit
get
():
(<!
UNSUPPORTED
!>
@Ann
<!>
x
:
Int
)->
Unit
=
{}
}
@Target
(
AnnotationTarget
.
TYPE
)
annotation
class
TypeAnn
val
onType
:
(
@TypeAnn
A
).(<!
UNSUPPORTED
!>
@Ann
<!>
a
:
@TypeAnn
A
,
@
<!
DEBUG_INFO_MISSING_UNRESOLVED
!>
TypeAnn
<
!
>
A
)->
@
<!
DEBUG_INFO_MISSING_UNRESOLVED
!>
TypeAnn
<
!
>
A
?
=
<!
EXPECTED_PARAMETERS_NUMBER_MISMATCH
!>{<!>
null
}
fun
(@
TypeAnn
A
).
extFun
(
@Ann
a
:
@TypeAnn
A
):
@
<!
DEBUG_INFO_MISSING_UNRESOLVED
!>
TypeAnn
<
!
>
A
?
=
null
\ No newline at end of file
compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.txt
0 → 100644
浏览文件 @
90849a67
package
public val inVal: (kotlin.Int) -> kotlin.Unit
public val onType: @TypeAnn() A.(@TypeAnn() A, A) -> A?
public fun f(/*0*/ @Ann() x: kotlin.Int): kotlin.Unit
public fun inParam(/*0*/ fn: (kotlin.Int) -> kotlin.Unit): kotlin.Unit
public fun inParamNested(/*0*/ fn1: ((kotlin.Int) -> kotlin.Unit) -> kotlin.Unit): kotlin.Unit
public fun inReturn(): (kotlin.Int) -> kotlin.Unit
public fun @TypeAnn() A.extFun(/*0*/ @Ann() a: @TypeAnn() A): A?
public final class A : (kotlin.Int) -> kotlin.Unit {
public constructor A()
public final val prop: (kotlin.Int) -> kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ fun invoke(/*0*/ p1: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@kotlin.annotation.annotation() public final class Ann : kotlin.Annotation {
public constructor Ann()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.annotation() public final class TypeAnn : kotlin.Annotation {
public constructor TypeAnn()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/typeReferenceError.kt
浏览文件 @
90849a67
package
typeReferenceError
<!
ABSTRACT_MEMBER_NOT_IMPLEMENTED
!>
class
Pair
<!><<!
SYNTAX
!><!>:(
val
c
:
<!
SYNTAX
!><!
SYNTAX
!><!>
fun
<!><!
SYNTAX
!><!>
<!
UNRESOLVED_REFERENCE
!>
main
<!>()
<!
ABSTRACT_MEMBER_NOT_IMPLEMENTED
!>
class
Pair
<!><<!
SYNTAX
!><!>:(<!
UNSUPPORTED
!>
val
<!>
c
:
<!
SYNTAX
!><!
SYNTAX
!><!>
fun
<!><!
SYNTAX
!><!>
<!
UNRESOLVED_REFERENCE
!>
main
<!>()
\ No newline at end of file
compiler/testData/diagnostics/tests/modifiers/modifierOnParameterInFunctionType.kt
0 → 100644
浏览文件 @
90849a67
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun
f
(
vararg
x
:
Int
)
{}
val
inVal
:
(<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
=
{}
fun
inParam
(
fn
:
(<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
)
{}
fun
inParamNested
(
fn1
:
(
fn2
:
(<!
UNSUPPORTED
!>
vararg
<!>
n
:
Int
)->
Unit
)->
Unit
)
{}
fun
inReturn
():
(<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
=
{}
class
A
:
(<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
{
override
fun
invoke
(
p1
:
Int
)
{
var
lambda
:
(<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
=
{}
}
val
prop
:
(<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
get
():
(<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
=
{}
}
val
allProhibited
:
(<!
UNSUPPORTED
!>
abstract
<!>
<!
UNSUPPORTED
!>
annotation
<!>
<!
UNSUPPORTED
!>
companion
<!>
<!
UNSUPPORTED
!>
const
<!>
<!
UNSUPPORTED
!>
crossinline
<!>
<!
UNSUPPORTED
!>
data
<!>
<!
UNSUPPORTED
!>
enum
<!>
<!
UNSUPPORTED
!>
external
<!>
<!
UNSUPPORTED
!>
final
<!>
<!
UNSUPPORTED
!>
in
<!>
<!
UNSUPPORTED
!>
inline
<!>
<!
UNSUPPORTED
!>
inner
<!>
<!
UNSUPPORTED
!>
internal
<!>
<!
UNSUPPORTED
!>
lateinit
<!>
<!
UNSUPPORTED
!>
noinline
<!>
<!
UNSUPPORTED
!>
open
<!>
<!
UNSUPPORTED
!>
operator
<!>
<!
UNSUPPORTED
!>
out
<!>
<!
UNSUPPORTED
!>
override
<!>
<!
UNSUPPORTED
!>
private
<!>
<!
UNSUPPORTED
!>
protected
<!>
<!
UNSUPPORTED
!>
public
<!>
<!
UNSUPPORTED
!>
reified
<!>
<!
UNSUPPORTED
!>
sealed
<!>
<!
UNSUPPORTED
!>
tailrec
<!>
<!
UNSUPPORTED
!>
vararg
<!>
x
:
Int
)->
Unit
=
{}
val
valProhibited
:
(<!
UNSUPPORTED
!>
val
<!>
x
:
Int
)->
Unit
=
{}
val
varProhibited
:
(<!
UNSUPPORTED
!>
var
<!>
x
:
Int
)->
Unit
=
{}
\ No newline at end of file
compiler/testData/diagnostics/tests/modifiers/modifierOnParameterInFunctionType.txt
0 → 100644
浏览文件 @
90849a67
package
public val allProhibited: (kotlin.Int) -> kotlin.Unit
public val inVal: (kotlin.Int) -> kotlin.Unit
public val valProhibited: (kotlin.Int) -> kotlin.Unit
public val varProhibited: (kotlin.Int) -> kotlin.Unit
public fun f(/*0*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
public fun inParam(/*0*/ fn: (kotlin.Int) -> kotlin.Unit): kotlin.Unit
public fun inParamNested(/*0*/ fn1: ((kotlin.Int) -> kotlin.Unit) -> kotlin.Unit): kotlin.Unit
public fun inReturn(): (kotlin.Int) -> kotlin.Unit
public final class A : (kotlin.Int) -> kotlin.Unit {
public constructor A()
public final val prop: (kotlin.Int) -> kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ fun invoke(/*0*/ p1: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java
浏览文件 @
90849a67
...
...
@@ -175,6 +175,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("DefaultValueForParameterInFunctionType.kt")
public void testDefaultValueForParameterInFunctionType() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DefaultValueForParameterInFunctionType.kt");
doTest(fileName);
}
@TestMetadata("DefaultValuesTypechecking.kt")
public void testDefaultValuesTypechecking() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt");
...
...
@@ -777,6 +783,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("annotationOnParameterInFunctionType.kt")
public void testAnnotationOnParameterInFunctionType() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.kt");
doTest(fileName);
}
@TestMetadata("AnnotationsForClasses.kt")
public void testAnnotationsForClasses() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.kt");
...
...
@@ -9411,6 +9423,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("modifierOnParameterInFunctionType.kt")
public void testModifierOnParameterInFunctionType() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/modifiers/modifierOnParameterInFunctionType.kt");
doTest(fileName);
}
@TestMetadata("NoLocalVisibility.kt")
public void testNoLocalVisibility() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/modifiers/NoLocalVisibility.kt");
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录