Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
6cee4e96
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,发现更多精彩内容 >>
提交
6cee4e96
编写于
1月 13, 2021
作者:
M
Mikhail Glukhikh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIR] Don't call componentX for anonymous destructuring entry
上级
795bd26e
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
37 addition
and
34 deletion
+37
-34
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt
...jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt
+1
-0
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
...s/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
+3
-2
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/DestructuringDeclaration.kt
...ains/kotlin/fir/lightTree/fir/DestructuringDeclaration.kt
+1
-1
compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt
...rc/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt
+1
-0
compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt
.../psi2fir/testData/rawBuilder/expressions/destructuring.kt
+4
-0
compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt
...tData/rawBuilder/expressions/destructuring.lazyBodies.txt
+1
-0
compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt
...psi2fir/testData/rawBuilder/expressions/destructuring.txt
+5
-0
compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt
...ns/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt
+1
-0
compiler/testData/codegen/box/destructuringDeclInLambdaParam/underscoreNames.kt
...gen/box/destructuringDeclInLambdaParam/underscoreNames.kt
+0
-1
compiler/testData/codegen/box/multiDecl/forRange/UnderscoreNamesDontCallComponent.kt
...ox/multiDecl/forRange/UnderscoreNamesDontCallComponent.kt
+0
-1
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt
...tructuringDeclarations/ForLoopMissingLoopParameter.fir.kt
+1
-1
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt
...rations/destructuringDeclarationAssignedUnresolved.fir.kt
+1
-1
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt
...rations/destructuringDeclarationMissingInitializer.fir.kt
+1
-1
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.fir.kt
...arationChecks/destructuringDeclarations/underscore.fir.kt
+7
-7
compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt
...functionLiterals/destructuringInLambdas/underscore.fir.kt
+10
-10
compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.kt.txt
...irText/expressions/destructuringWithUnderscore.fir.kt.txt
+0
-1
compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt
...ir/irText/expressions/destructuringWithUnderscore.fir.txt
+0
-4
compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt
...stData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt
+0
-1
compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt
.../testData/ir/irText/lambdas/destructuringInLambda.fir.txt
+0
-3
未找到文件。
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt
浏览文件 @
6cee4e96
...
...
@@ -112,6 +112,7 @@ fun generateDestructuringBlock(
}
val
isVar
=
multiDeclaration
.
isVar
for
((
index
,
entry
)
in
multiDeclaration
.
entries
.
withIndex
())
{
if
(
entry
==
null
)
continue
statements
+=
buildProperty
{
this
.
session
=
session
origin
=
FirDeclarationOrigin
.
Source
...
...
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
浏览文件 @
6cee4e96
...
...
@@ -1068,7 +1068,7 @@ class DeclarationsConverter(
*/
private
fun
convertDestructingDeclaration
(
destructingDeclaration
:
LighterASTNode
):
DestructuringDeclaration
{
var
isVar
=
false
val
entries
=
mutableListOf
<
FirVariable
<
*
>>()
val
entries
=
mutableListOf
<
FirVariable
<
*
>
?
>()
val
source
=
destructingDeclaration
.
toFirSourceElement
()
var
firExpression
:
FirExpression
=
buildErrorExpression
(
null
,
ConeSimpleDiagnostic
(
"Initializer required for destructuring declaration"
,
DiagnosticKind
.
Syntax
))
...
...
@@ -1087,7 +1087,7 @@ class DeclarationsConverter(
/**
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseMultiDeclarationName
*/
private
fun
convertDestructingDeclarationEntry
(
entry
:
LighterASTNode
):
FirVariable
<
*
>
{
private
fun
convertDestructingDeclarationEntry
(
entry
:
LighterASTNode
):
FirVariable
<
*
>
?
{
var
modifiers
=
Modifier
()
var
identifier
:
String
?
=
null
var
firType
:
FirTypeRef
?
=
null
...
...
@@ -1099,6 +1099,7 @@ class DeclarationsConverter(
}
}
if
(
identifier
==
"_"
)
return
null
val
name
=
identifier
.
nameAsSafeName
()
return
buildProperty
{
source
=
entry
.
toFirSourceElement
()
...
...
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/DestructuringDeclaration.kt
浏览文件 @
6cee4e96
...
...
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.fir.lightTree.converter.generateDestructuringBlock
data class
DestructuringDeclaration
(
val
isVar
:
Boolean
,
val
entries
:
List
<
FirVariable
<
*
>>,
val
entries
:
List
<
FirVariable
<
*
>
?
>,
val
initializer
:
FirExpression
,
val
source
:
FirSourceElement
)
{
...
...
compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt
浏览文件 @
6cee4e96
...
...
@@ -96,6 +96,7 @@ internal fun generateDestructuringBlock(
}
val
isVar
=
multiDeclaration
.
isVar
for
((
index
,
entry
)
in
multiDeclaration
.
entries
.
withIndex
())
{
if
(
entry
.
nameIdentifier
?.
text
==
"_"
)
continue
val
entrySource
=
entry
.
toFirPsiSourceElement
()
val
name
=
entry
.
nameAsSafeName
statements
+=
buildProperty
{
...
...
compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt
浏览文件 @
6cee4e96
...
...
@@ -6,4 +6,8 @@ fun foo(some: Some) {
x
++
y
*=
2.0
z
=
""
}
fun
bar
(
some
:
Some
)
{
val
(
a
,
_
,
`_`
)
=
some
}
\ No newline at end of file
compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt
浏览文件 @
6cee4e96
...
...
@@ -23,3 +23,4 @@ FILE: destructuring.kt
}
public? final? fun foo(some: Some): R|kotlin/Unit| { LAZY_BLOCK }
public? final? fun bar(some: Some): R|kotlin/Unit| { LAZY_BLOCK }
compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt
浏览文件 @
6cee4e96
...
...
@@ -33,3 +33,8 @@ FILE: destructuring.kt
*=(y#, Double(2.0))
z# = String()
}
public? final? fun bar(some: Some): R|kotlin/Unit| {
lval <destruct>: <implicit> = some#
lval a: <implicit> = R|<local>/<destruct>|.component1#()
lval _: <implicit> = R|<local>/<destruct>|.component3#()
}
compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt
浏览文件 @
6cee4e96
...
...
@@ -264,6 +264,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
it
.
getStrictParentOfType
<
KtPackageDirective
>()
!=
null
||
it
.
getStrictParentOfType
<
KtImportDirective
>()
!=
null
||
(
it
is
KtPropertyAccessor
&&
!
it
.
hasBody
())
||
it
is
KtDestructuringDeclarationEntry
&&
it
.
text
==
"_"
||
it
is
KtConstantExpression
&&
it
.
parent
.
let
{
parent
->
parent
is
KtPrefixExpression
&&
(
parent
.
operationToken
==
KtTokens
.
MINUS
||
parent
.
operationToken
==
KtTokens
.
PLUS
)
}
...
...
compiler/testData/codegen/box/destructuringDeclInLambdaParam/underscoreNames.kt
浏览文件 @
6cee4e96
// IGNORE_BACKEND_FIR: JVM_IR
class
A
{
operator
fun
component1
()
=
"O"
operator
fun
component2
():
String
=
throw
RuntimeException
(
"fail 0"
)
...
...
compiler/testData/codegen/box/multiDecl/forRange/UnderscoreNamesDontCallComponent.kt
浏览文件 @
6cee4e96
// IGNORE_BACKEND_FIR: JVM_IR
class
A
{
operator
fun
component1
()
=
"O"
operator
fun
component2
():
String
=
throw
RuntimeException
(
"fail 0"
)
...
...
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt
浏览文件 @
6cee4e96
...
...
@@ -7,7 +7,7 @@ fun useDeclaredVariables() {
}
fun
checkersShouldRun
()
{
<!
UNRESOLVED_REFERENCE
,
UNRESOLVED_REFERENCE
,
UNRESOLVED_REFERENCE
!>
for
((<!
UNRESOLVED_REFERENCE
!>
@A
a
<!>,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)<!
SYNTAX
!><!>)
{
<!
UNRESOLVED_REFERENCE
,
UNRESOLVED_REFERENCE
,
UNRESOLVED_REFERENCE
!>
for
((<!
UNRESOLVED_REFERENCE
!>
@A
a
<!>,
_
)<!
SYNTAX
!><!>)
{
}<!>
}
...
...
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt
浏览文件 @
6cee4e96
...
...
@@ -5,7 +5,7 @@ fun useDeclaredVariables() {
}
fun
checkersShouldRun
()
{
val
(
<!
UNRESOLVED_REFERENCE
!>@
A
a
<!>
,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)
=
<!
UNRESOLVED_REFERENCE
!>
unresolved
<!>
val
(
<!
UNRESOLVED_REFERENCE
!>@
A
a
<!>
,
_
)
=
<!
UNRESOLVED_REFERENCE
!>
unresolved
<!>
}
annotation
class
A
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt
浏览文件 @
6cee4e96
...
...
@@ -5,7 +5,7 @@ fun useDeclaredVariables() {
}
fun
checkersShouldRun
()
{
<!
INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION
!>
val
(
<!
UNRESOLVED_REFERENCE
!>@
A
a
<!>
,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)<!>
<!
INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION
!>
val
(
<!
UNRESOLVED_REFERENCE
!>@
A
a
<!>
,
_
)<!>
}
annotation
class
A
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.fir.kt
浏览文件 @
6cee4e96
...
...
@@ -11,31 +11,31 @@ class C {
fun
test
()
{
for
((
x
,
_
)
in
C
())
{
foo
(
x
,
_
)
foo
(
x
,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)
}
for
((
_
,
y
)
in
C
())
{
foo
(
_
,
y
)
foo
(
<!
UNRESOLVED_REFERENCE
!>
_
<!>
,
y
)
}
for
((
_
,
_
)
in
C
())
{
<!
INAPPLICABLE_CANDIDATE
!>
foo
<!>(
_
,
_
)
foo
(<!
UNRESOLVED_REFERENCE
!>
_
<!>,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)
}
for
((
_
:
Int
,
_
:
String
)
in
C
())
{
<!
INAPPLICABLE_CANDIDATE
!>
foo
<!>(
_
,
_
)
foo
(<!
UNRESOLVED_REFERENCE
!>
_
<!>,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)
}
for
((
_
:
String
,
_
:
Int
)
in
C
())
{
<!
INAPPLICABLE_CANDIDATE
!>
foo
<!>(
_
,
_
)
foo
(<!
UNRESOLVED_REFERENCE
!>
_
<!>,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)
}
val
(
x
,
_
)
=
A
()
val
(
_
,
y
)
=
A
()
foo
(
x
,
y
)
<!
INAPPLICABLE_CANDIDATE
!>
foo
<!>(
x
,
_
)
foo
(
_
,
y
)
foo
(
x
,
<!
UNRESOLVED_REFERENCE
!>
_
<!>
)
foo
(
<!
UNRESOLVED_REFERENCE
!>
_
<!>
,
y
)
val
(
`_`
,
z
)
=
A
()
...
...
compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt
浏览文件 @
6cee4e96
...
...
@@ -8,39 +8,39 @@ fun foo(block: (A) -> Unit) { }
fun
bar
()
{
foo
{
(
_
,
b
)
->
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
b
checkType
{
_
<
String
>()
}
}
foo
{
(
a
,
_
)
->
a
checkType
{
_
<
Int
>()
}
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
}
foo
{
(
_
,
_
)
->
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
}
foo
{
(
_
:
Int
,
b
:
String
)
->
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
b
checkType
{
_
<
String
>()
}
}
foo
{
(
a
:
Int
,
_
:
String
)
->
a
checkType
{
_
<
Int
>()
}
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
}
foo
{
(
_
:
Int
,
_
:
String
)
->
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
}
foo
{
(
_
,
_
):
A
->
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
}
foo
{
(
`_`
,
_
)
->
_
checkType
{
<!
INAPPLICABLE_CANDIDATE
!>
_
<!>
<
Int
>()
}
_
checkType
{
_
<
Int
>()
}
}
foo
{
(
_
,
`_`
)
->
...
...
@@ -52,12 +52,12 @@ fun bar() {
}
foo
{
(
_
:
String
,
b
)
->
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
b
checkType
{
_
<
String
>()
}
}
foo
{
(
_
,
b
):
B
->
_
.
hashCode
()
<!
UNRESOLVED_REFERENCE
!>
_
<!>.<!
UNRESOLVED_REFERENCE
!>
hashCode
<!>
()
b
checkType
{
<!
INAPPLICABLE_CANDIDATE
!>
_
<!><
Short
>()
}
}
}
compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.kt.txt
浏览文件 @
6cee4e96
...
...
@@ -31,6 +31,5 @@ object B {
fun B.test() {
val <destruct>: A = A
val x: Int = (<this>, <destruct>).component1()
val _: Int = (<this>, <destruct>).component2()
val z: Int = (<this>, <destruct>).component3()
}
compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt
浏览文件 @
6cee4e96
...
...
@@ -64,10 +64,6 @@ FILE fqName:<root> fileName:/destructuringWithUnderscore.kt
CALL 'public final fun component1 (): kotlin.Int [operator] declared in <root>.B' type=kotlin.Int origin=null
$this: GET_VAR '<this>: <root>.B declared in <root>.test' type=<root>.B origin=null
$receiver: GET_VAR 'val tmp_0: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
VAR name:_ type:kotlin.Int [val]
CALL 'public final fun component2 (): kotlin.Int [operator] declared in <root>.B' type=kotlin.Int origin=null
$this: GET_VAR '<this>: <root>.B declared in <root>.test' type=<root>.B origin=null
$receiver: GET_VAR 'val tmp_0: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
VAR name:z type:kotlin.Int [val]
CALL 'public final fun component3 (): kotlin.Int [operator] declared in <root>.B' type=kotlin.Int origin=null
$this: GET_VAR '<this>: <root>.B declared in <root>.test' type=<root>.B origin=null
...
...
compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt
浏览文件 @
6cee4e96
...
...
@@ -56,7 +56,6 @@ data class A {
var fn: Function1<A, Int>
field = local fun <anonymous>(<destruct>: A): Int {
val _: Int = <destruct>.component1()
val y: Int = <destruct>.component2()
return 42.plus(other = y)
}
...
...
compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt
浏览文件 @
6cee4e96
...
...
@@ -142,9 +142,6 @@ FILE fqName:<root> fileName:/destructuringInLambda.kt
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (<destruct>:<root>.A) returnType:kotlin.Int
VALUE_PARAMETER name:<destruct> index:0 type:<root>.A
BLOCK_BODY
VAR name:_ type:kotlin.Int [val]
CALL 'public final fun component1 (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=null
$this: GET_VAR '<destruct>: <root>.A declared in <root>.fn.<anonymous>' type=<root>.A origin=null
VAR name:y type:kotlin.Int [val]
CALL 'public final fun component2 (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=null
$this: GET_VAR '<destruct>: <root>.A declared in <root>.fn.<anonymous>' type=<root>.A origin=null
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录