Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
30e5748f
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,发现更多精彩内容 >>
提交
30e5748f
编写于
5月 12, 2020
作者:
J
Jinseong Jeon
提交者:
Mikhail Glukhikh
5月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FIR: set proper visibility of property accessors.
上级
5d724a8c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
49 addition
and
19 deletion
+49
-19
compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.txt
...estData/resolveWithStdlib/callableReferences/ifWithCR.txt
+2
-2
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
...s/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
+29
-8
compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
...fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
+18
-4
compiler/testData/codegen/box/classes/kt2477.kt
compiler/testData/codegen/box/classes/kt2477.kt
+0
-1
compiler/testData/codegen/box/jvm8/defaults/privateInDefaultImpls.kt
...stData/codegen/box/jvm8/defaults/privateInDefaultImpls.kt
+0
-1
compiler/testData/codegen/box/regressions/kt13381.kt
compiler/testData/codegen/box/regressions/kt13381.kt
+0
-1
compiler/testData/codegen/box/traits/traitWithPrivateMember.kt
...ler/testData/codegen/box/traits/traitWithPrivateMember.kt
+0
-1
compiler/testData/codegen/box/traits/traitWithPrivateMemberAccessFromLambda.kt
...egen/box/traits/traitWithPrivateMemberAccessFromLambda.kt
+0
-1
未找到文件。
compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.txt
浏览文件 @
30e5748f
FILE: ifWithCR.kt
FILE: ifWithCR.kt
private final var R|kotlin/Int|.readOnlyWrapper: R|kotlin/CharSequence?|
private final var R|kotlin/Int|.readOnlyWrapper: R|kotlin/CharSequence?|
p
ublic
get(): R|kotlin/CharSequence?| {
p
rivate
get(): R|kotlin/CharSequence?| {
^ Null(null)
^ Null(null)
}
}
private set(value: R|kotlin/CharSequence?|): R|kotlin/Unit|
private set(value: R|kotlin/CharSequence?|): R|kotlin/Unit|
private final var R|kotlin/Int|.mutableWrapper: R|kotlin/CharSequence?|
private final var R|kotlin/Int|.mutableWrapper: R|kotlin/CharSequence?|
p
ublic
get(): R|kotlin/CharSequence?| {
p
rivate
get(): R|kotlin/CharSequence?| {
^ Null(null)
^ Null(null)
}
}
private set(value: R|kotlin/CharSequence?|): R|kotlin/Unit|
private set(value: R|kotlin/CharSequence?|): R|kotlin/Unit|
...
...
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
浏览文件 @
30e5748f
...
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.KtNodeTypes.*
...
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.KtNodeTypes.*
import
org.jetbrains.kotlin.descriptors.ClassKind
import
org.jetbrains.kotlin.descriptors.ClassKind
import
org.jetbrains.kotlin.descriptors.Modality
import
org.jetbrains.kotlin.descriptors.Modality
import
org.jetbrains.kotlin.descriptors.Visibilities
import
org.jetbrains.kotlin.descriptors.Visibilities
import
org.jetbrains.kotlin.descriptors.Visibility
import
org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import
org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import
org.jetbrains.kotlin.fir.*
import
org.jetbrains.kotlin.fir.*
import
org.jetbrains.kotlin.fir.builder.Context
import
org.jetbrains.kotlin.fir.builder.Context
...
@@ -664,7 +665,11 @@ class DeclarationsConverter(
...
@@ -664,7 +665,11 @@ class DeclarationsConverter(
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseClassOrObject
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseClassOrObject
* primaryConstructor branch
* primaryConstructor branch
*/
*/
private
fun
convertPrimaryConstructor
(
primaryConstructor
:
LighterASTNode
?,
classWrapper
:
ClassWrapper
,
delegatedConstructorSource
:
FirLightSourceElement
?):
PrimaryConstructor
?
{
private
fun
convertPrimaryConstructor
(
primaryConstructor
:
LighterASTNode
?,
classWrapper
:
ClassWrapper
,
delegatedConstructorSource
:
FirLightSourceElement
?
):
PrimaryConstructor
?
{
if
(
primaryConstructor
==
null
&&
!
classWrapper
.
isEnumEntry
()
&&
classWrapper
.
hasSecondaryConstructor
)
return
null
if
(
primaryConstructor
==
null
&&
!
classWrapper
.
isEnumEntry
()
&&
classWrapper
.
hasSecondaryConstructor
)
return
null
if
(
classWrapper
.
isInterface
())
return
null
if
(
classWrapper
.
isInterface
())
return
null
...
@@ -939,7 +944,8 @@ class DeclarationsConverter(
...
@@ -939,7 +944,8 @@ class DeclarationsConverter(
}
}
}
}
status
=
FirDeclarationStatusImpl
(
modifiers
.
getVisibility
(),
modifiers
.
getModality
()).
apply
{
val
propertyVisibility
=
modifiers
.
getVisibility
()
status
=
FirDeclarationStatusImpl
(
propertyVisibility
,
modifiers
.
getModality
()).
apply
{
isExpect
=
modifiers
.
hasExpect
()
isExpect
=
modifiers
.
hasExpect
()
isActual
=
modifiers
.
hasActual
()
isActual
=
modifiers
.
hasActual
()
isOverride
=
modifiers
.
hasOverride
()
isOverride
=
modifiers
.
hasOverride
()
...
@@ -948,13 +954,13 @@ class DeclarationsConverter(
...
@@ -948,13 +954,13 @@ class DeclarationsConverter(
}
}
val
convertedAccessors
=
accessors
.
map
{
convertGetterOrSetter
(
it
,
returnType
)
}
val
convertedAccessors
=
accessors
.
map
{
convertGetterOrSetter
(
it
,
returnType
,
propertyVisibility
)
}
this
.
getter
=
convertedAccessors
.
find
{
it
.
isGetter
}
this
.
getter
=
convertedAccessors
.
find
{
it
.
isGetter
}
?:
FirDefaultPropertyGetter
(
null
,
session
,
FirDeclarationOrigin
.
Source
,
returnType
,
modifiers
.
getVisibility
()
)
?:
FirDefaultPropertyGetter
(
null
,
session
,
FirDeclarationOrigin
.
Source
,
returnType
,
propertyVisibility
)
this
.
setter
=
this
.
setter
=
if
(
isVar
)
{
if
(
isVar
)
{
convertedAccessors
.
find
{
it
.
isSetter
}
convertedAccessors
.
find
{
it
.
isSetter
}
?:
FirDefaultPropertySetter
(
null
,
session
,
FirDeclarationOrigin
.
Source
,
returnType
,
modifiers
.
getVisibility
()
)
?:
FirDefaultPropertySetter
(
null
,
session
,
FirDeclarationOrigin
.
Source
,
returnType
,
propertyVisibility
)
}
else
null
}
else
null
val
receiver
=
delegateExpression
?.
let
{
val
receiver
=
delegateExpression
?.
let
{
...
@@ -1027,7 +1033,11 @@ class DeclarationsConverter(
...
@@ -1027,7 +1033,11 @@ class DeclarationsConverter(
/**
/**
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parsePropertyGetterOrSetter
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parsePropertyGetterOrSetter
*/
*/
private
fun
convertGetterOrSetter
(
getterOrSetter
:
LighterASTNode
,
propertyTypeRef
:
FirTypeRef
):
FirPropertyAccessor
{
private
fun
convertGetterOrSetter
(
getterOrSetter
:
LighterASTNode
,
propertyTypeRef
:
FirTypeRef
,
propertyVisibility
:
Visibility
):
FirPropertyAccessor
{
var
modifiers
=
Modifier
()
var
modifiers
=
Modifier
()
var
isGetter
=
true
var
isGetter
=
true
var
returnType
:
FirTypeRef
?
=
null
var
returnType
:
FirTypeRef
?
=
null
...
@@ -1051,10 +1061,21 @@ class DeclarationsConverter(
...
@@ -1051,10 +1061,21 @@ class DeclarationsConverter(
}
}
}
}
var
accessorVisibility
=
modifiers
.
getVisibility
()
if
(
accessorVisibility
==
Visibilities
.
UNKNOWN
)
{
accessorVisibility
=
propertyVisibility
}
val
sourceElement
=
getterOrSetter
.
toFirSourceElement
()
val
sourceElement
=
getterOrSetter
.
toFirSourceElement
()
if
(
block
==
null
&&
expression
==
null
)
{
if
(
block
==
null
&&
expression
==
null
)
{
return
FirDefaultPropertyAccessor
return
FirDefaultPropertyAccessor
.
createGetterOrSetter
(
sourceElement
,
baseSession
,
FirDeclarationOrigin
.
Source
,
propertyTypeRef
,
modifiers
.
getVisibility
(),
isGetter
)
.
createGetterOrSetter
(
sourceElement
,
baseSession
,
FirDeclarationOrigin
.
Source
,
propertyTypeRef
,
accessorVisibility
,
isGetter
)
.
also
{
.
also
{
it
.
annotations
+=
modifiers
.
annotations
it
.
annotations
+=
modifiers
.
annotations
}
}
...
@@ -1067,7 +1088,7 @@ class DeclarationsConverter(
...
@@ -1067,7 +1088,7 @@ class DeclarationsConverter(
returnTypeRef
=
returnType
?:
if
(
isGetter
)
propertyTypeRef
else
implicitUnitType
returnTypeRef
=
returnType
?:
if
(
isGetter
)
propertyTypeRef
else
implicitUnitType
symbol
=
FirPropertyAccessorSymbol
()
symbol
=
FirPropertyAccessorSymbol
()
this
.
isGetter
=
isGetter
this
.
isGetter
=
isGetter
status
=
FirDeclarationStatusImpl
(
modifiers
.
getVisibility
()
,
Modality
.
FINAL
)
status
=
FirDeclarationStatusImpl
(
accessorVisibility
,
Modality
.
FINAL
)
context
.
firFunctionTargets
+=
target
context
.
firFunctionTargets
+=
target
annotations
+=
modifiers
.
annotations
annotations
+=
modifiers
.
annotations
...
...
compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
浏览文件 @
30e5748f
...
@@ -267,11 +267,19 @@ class RawFirBuilder(
...
@@ -267,11 +267,19 @@ class RawFirBuilder(
propertyTypeRef
:
FirTypeRef
,
propertyTypeRef
:
FirTypeRef
,
isGetter
:
Boolean
,
isGetter
:
Boolean
,
):
FirPropertyAccessor
{
):
FirPropertyAccessor
{
val
accessorVisibility
=
if
(
this
?.
visibility
!=
null
&&
this
.
visibility
!=
Visibilities
.
UNKNOWN
)
this
.
visibility
else
property
.
visibility
if
(
this
==
null
||
!
hasBody
())
{
if
(
this
==
null
||
!
hasBody
())
{
val
propertySource
=
property
.
toFirSourceElement
()
val
propertySource
=
property
.
toFirSourceElement
()
val
accessorVisibility
=
this
?.
visibility
?:
property
.
visibility
return
FirDefaultPropertyAccessor
return
FirDefaultPropertyAccessor
.
createGetterOrSetter
(
propertySource
,
baseSession
,
FirDeclarationOrigin
.
Source
,
propertyTypeRef
,
accessorVisibility
,
isGetter
)
.
createGetterOrSetter
(
propertySource
,
baseSession
,
FirDeclarationOrigin
.
Source
,
propertyTypeRef
,
accessorVisibility
,
isGetter
)
.
also
{
.
also
{
if
(
this
!=
null
)
{
if
(
this
!=
null
)
{
it
.
extractAnnotationsFrom
(
this
)
it
.
extractAnnotationsFrom
(
this
)
...
@@ -290,7 +298,7 @@ class RawFirBuilder(
...
@@ -290,7 +298,7 @@ class RawFirBuilder(
returnTypeReference
.
toFirOrUnitType
()
returnTypeReference
.
toFirOrUnitType
()
}
}
this
.
isGetter
=
isGetter
this
.
isGetter
=
isGetter
status
=
FirDeclarationStatusImpl
(
v
isibility
,
Modality
.
FINAL
)
status
=
FirDeclarationStatusImpl
(
accessorV
isibility
,
Modality
.
FINAL
)
extractAnnotationsTo
(
this
)
extractAnnotationsTo
(
this
)
this
@RawFirBuilder
.
context
.
firFunctionTargets
+=
accessorTarget
this
@RawFirBuilder
.
context
.
firFunctionTargets
+=
accessorTarget
extractValueParametersTo
(
this
,
propertyTypeRef
)
extractValueParametersTo
(
this
,
propertyTypeRef
)
...
@@ -374,7 +382,13 @@ class RawFirBuilder(
...
@@ -374,7 +382,13 @@ class RawFirBuilder(
isLocal
=
false
isLocal
=
false
this
.
status
=
status
this
.
status
=
status
getter
=
FirDefaultPropertyGetter
(
propertySource
,
baseSession
,
FirDeclarationOrigin
.
Source
,
type
,
visibility
)
getter
=
FirDefaultPropertyGetter
(
propertySource
,
baseSession
,
FirDeclarationOrigin
.
Source
,
type
,
visibility
)
setter
=
if
(
isMutable
)
FirDefaultPropertySetter
(
propertySource
,
baseSession
,
FirDeclarationOrigin
.
Source
,
type
,
visibility
)
else
null
setter
=
if
(
isMutable
)
FirDefaultPropertySetter
(
propertySource
,
baseSession
,
FirDeclarationOrigin
.
Source
,
type
,
visibility
)
else
null
extractAnnotationsTo
(
this
)
extractAnnotationsTo
(
this
)
}
}
}
}
...
...
compiler/testData/codegen/box/classes/kt2477.kt
浏览文件 @
30e5748f
// IGNORE_BACKEND_FIR: JVM_IR
package
test
package
test
interface
A
{
interface
A
{
...
...
compiler/testData/codegen/box/jvm8/defaults/privateInDefaultImpls.kt
浏览文件 @
30e5748f
// !JVM_DEFAULT_MODE: enable
// !JVM_DEFAULT_MODE: enable
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// JVM_TARGET: 1.8
// WITH_RUNTIME
// WITH_RUNTIME
...
...
compiler/testData/codegen/box/regressions/kt13381.kt
浏览文件 @
30e5748f
// IGNORE_BACKEND_FIR: JVM_IR
interface
A
{
interface
A
{
// There must be no delegation methods for 'log' and 'bar' in C as they are private
// There must be no delegation methods for 'log' and 'bar' in C as they are private
private
val
log
:
String
get
()
=
"O"
private
val
log
:
String
get
()
=
"O"
...
...
compiler/testData/codegen/box/traits/traitWithPrivateMember.kt
浏览文件 @
30e5748f
// IGNORE_BACKEND_FIR: JVM_IR
interface
Z
{
interface
Z
{
fun
testFun
()
:
String
{
fun
testFun
()
:
String
{
...
...
compiler/testData/codegen/box/traits/traitWithPrivateMemberAccessFromLambda.kt
浏览文件 @
30e5748f
// IGNORE_BACKEND_FIR: JVM_IR
interface
Z
{
interface
Z
{
fun
testFun
():
String
{
fun
testFun
():
String
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录