Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
38922a84
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,发现更多精彩内容 >>
提交
38922a84
编写于
6月 08, 2020
作者:
D
Denis Zharkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FIR: Do not create synthetic properties for non-Java accessors
^KT-35495 Fixed
上级
6a1f921a
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
51 addition
and
40 deletion
+51
-40
compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorConversion.kt
...sts/testData/resolve/properties/javaAccessorConversion.kt
+2
-2
compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorConversion.txt
...ts/testData/resolve/properties/javaAccessorConversion.txt
+1
-1
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java
...org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java
+5
-5
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java
.../kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java
+5
-5
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt
.../src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt
+20
-5
compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt
...rg/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt
+9
-0
compiler/testData/codegen/box/objects/objectLiteralInClass.kt
...iler/testData/codegen/box/objects/objectLiteralInClass.kt
+0
-2
compiler/testData/codegen/box/properties/kt4252.kt
compiler/testData/codegen/box/properties/kt4252.kt
+1
-2
compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt
...gen/box/properties/lateinit/topLevel/accessorException.kt
+0
-4
compiler/testData/codegen/box/properties/lateinit/topLevel/accessorForTopLevelLateinit.kt
...operties/lateinit/topLevel/accessorForTopLevelLateinit.kt
+0
-4
compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.fir.kt
...OnCallingPureKotlinFunctionAsSyntheticJavaAccessor.fir.kt
+0
-3
compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt
...sionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt
+1
-0
compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/Bases.fir.kt
...ics/tests/syntheticExtensions/javaProperties/Bases.fir.kt
+3
-3
compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/Getter.fir.kt
...cs/tests/syntheticExtensions/javaProperties/Getter.fir.kt
+2
-2
compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/KotlinOverridesJava.fir.kt
...heticExtensions/javaProperties/KotlinOverridesJava.fir.kt
+2
-2
未找到文件。
compiler/fir/analysis-tests/testData/resolve/pro
blem
s/javaAccessorConversion.kt
→
compiler/fir/analysis-tests/testData/resolve/pro
pertie
s/javaAccessorConversion.kt
浏览文件 @
38922a84
...
...
@@ -74,9 +74,9 @@ class Foo {
}
fun
test_4
(
foo
:
Foo
)
{
foo
.
x
// should be error
foo
.
<!
UNRESOLVED_REFERENCE
!>
x
<!>
// should be error
}
fun
test_5
(
x
:
D
)
{
x
.
isGood
}
\ No newline at end of file
}
compiler/fir/analysis-tests/testData/resolve/pro
blem
s/javaAccessorConversion.txt
→
compiler/fir/analysis-tests/testData/resolve/pro
pertie
s/javaAccessorConversion.txt
浏览文件 @
38922a84
...
...
@@ -22,7 +22,7 @@ FILE: main.kt
}
public final fun test_4(foo: R|Foo|): R|kotlin/Unit| {
R|<local>/foo|.
R|/Foo.x|
R|<local>/foo|.
<Unresolved name: x>#
}
public final fun test_5(x: R|D|): R|kotlin/Unit| {
R|<local>/x|.R|/D.isGood|
...
...
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java
浏览文件 @
38922a84
...
...
@@ -1689,11 +1689,6 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest
(
"compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt"
);
}
@TestMetadata
(
"javaAccessorConversion.kt"
)
public
void
testJavaAccessorConversion
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/problems/javaAccessorConversion.kt"
);
}
@TestMetadata
(
"javaQualifier.kt"
)
public
void
testJavaQualifier
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.kt"
);
...
...
@@ -1732,6 +1727,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
KotlinTestUtils
.
assertAllTestsPresentByMetadataWithExcluded
(
this
.
getClass
(),
new
File
(
"compiler/fir/analysis-tests/testData/resolve/properties"
),
Pattern
.
compile
(
"^([^.]+)\\.kt$"
),
null
,
true
);
}
@TestMetadata
(
"javaAccessorConversion.kt"
)
public
void
testJavaAccessorConversion
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorConversion.kt"
);
}
@TestMetadata
(
"noBackingFieldForExtension.kt"
)
public
void
testNoBackingFieldForExtension
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/properties/noBackingFieldForExtension.kt"
);
...
...
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java
浏览文件 @
38922a84
...
...
@@ -1689,11 +1689,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest
(
"compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt"
);
}
@TestMetadata
(
"javaAccessorConversion.kt"
)
public
void
testJavaAccessorConversion
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/problems/javaAccessorConversion.kt"
);
}
@TestMetadata
(
"javaQualifier.kt"
)
public
void
testJavaQualifier
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.kt"
);
...
...
@@ -1732,6 +1727,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
KotlinTestUtils
.
assertAllTestsPresentByMetadataWithExcluded
(
this
.
getClass
(),
new
File
(
"compiler/fir/analysis-tests/testData/resolve/properties"
),
Pattern
.
compile
(
"^([^.]+)\\.kt$"
),
null
,
true
);
}
@TestMetadata
(
"javaAccessorConversion.kt"
)
public
void
testJavaAccessorConversion
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorConversion.kt"
);
}
@TestMetadata
(
"noBackingFieldForExtension.kt"
)
public
void
testNoBackingFieldForExtension
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/properties/noBackingFieldForExtension.kt"
);
...
...
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt
浏览文件 @
38922a84
...
...
@@ -6,17 +6,17 @@
package
org.jetbrains.kotlin.fir.resolve.calls
import
org.jetbrains.kotlin.fir.FirSession
import
org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
import
org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
import
org.jetbrains.kotlin.fir.declarations.isStatic
import
org.jetbrains.kotlin.fir.declarations.synthetic.buildSyntheticProperty
import
org.jetbrains.kotlin.fir.scopes.FirScope
import
org.jetbrains.kotlin.fir.scopes.ProcessorAction
import
org.jetbrains.kotlin.fir.scopes.processOverriddenFunctionsAndSelf
import
org.jetbrains.kotlin.fir.symbols.CallableId
import
org.jetbrains.kotlin.fir.symbols.StandardClassIds
import
org.jetbrains.kotlin.fir.symbols.SyntheticSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirAccessorSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.*
import
org.jetbrains.kotlin.fir.types.ConeClassLikeType
import
org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import
org.jetbrains.kotlin.load.java.propertyNameByGetMethodName
...
...
@@ -52,6 +52,8 @@ class FirSyntheticPropertiesScope(
val
getterReturnType
=
(
getter
.
returnTypeRef
as
?
FirResolvedTypeRef
)
?.
type
if
((
getterReturnType
as
?
ConeClassLikeType
)
?.
lookupTag
?.
classId
==
StandardClassIds
.
Unit
)
return
if
(!
getterSymbol
.
hasJavaOverridden
())
return
var
matchingSetter
:
FirSimpleFunction
?
=
null
if
(
getterReturnType
!=
null
)
{
val
setterName
=
setterNameByGetterName
(
getterName
)
...
...
@@ -79,6 +81,20 @@ class FirSyntheticPropertiesScope(
processor
(
property
.
symbol
)
}
private
fun
FirFunctionSymbol
<*>.
hasJavaOverridden
():
Boolean
{
var
result
=
false
baseScope
.
processOverriddenFunctionsAndSelf
(
this
)
{
if
(
it
.
unwrapOverridden
().
fir
.
origin
==
FirDeclarationOrigin
.
Enhancement
)
{
result
=
true
ProcessorAction
.
STOP
}
else
{
ProcessorAction
.
NEXT
}
}
return
result
}
override
fun
processPropertiesByName
(
name
:
Name
,
processor
:
(
FirVariableSymbol
<
*
>)
->
Unit
)
{
val
getterNames
=
possibleGetterNamesByPropertyName
(
name
)
for
(
getterName
in
getterNames
)
{
...
...
@@ -118,4 +134,3 @@ class FirSyntheticPropertiesScope(
private
const
val
IS_PREFIX
=
"is"
}
}
compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt
浏览文件 @
38922a84
...
...
@@ -21,3 +21,12 @@ inline fun <reified E : FirCallableSymbol<*>> E.unwrapOverriddenOnce(): E {
return
this
}
inline
fun
<
reified
E
:
FirCallableSymbol
<
*
>>
E
.
unwrapOverridden
():
E
{
var
current
=
this
while
(
current
.
overriddenSymbol
!=
null
)
{
current
=
current
.
overriddenSymbol
as
E
}
return
current
}
compiler/testData/codegen/box/objects/objectLiteralInClass.kt
浏览文件 @
38922a84
// IGNORE_BACKEND_FIR: JVM_IR
class
C
{
val
s
=
"OK"
...
...
compiler/testData/codegen/box/properties/kt4252.kt
浏览文件 @
38922a84
// IGNORE_BACKEND_FIR: JVM_IR
class
CallbackBlock
{}
public
class
Foo
...
...
@@ -21,4 +20,4 @@ fun box() : String {
if
(
foo
.
getBar
()
!=
1
)
return
"Fail"
;
return
"OK"
}
\ No newline at end of file
}
compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt
浏览文件 @
38922a84
// IGNORE_BACKEND_FIR: JVM_IR
// Note: does not pass on FIR because of non-prohibited Kotlin synthetic properties,
// fun getS() = s is considered to be recursive here :(
// It's a question to be discussed in Dec 2019. Muted at this moment.
// WITH_RUNTIME
// FILE: lateinit.kt
private
lateinit
var
s
:
String
...
...
compiler/testData/codegen/box/properties/lateinit/topLevel/accessorForTopLevelLateinit.kt
浏览文件 @
38922a84
// IGNORE_BACKEND_FIR: JVM_IR
// Note: does not pass on FIR because of non-prohibited Kotlin synthetic properties,
// fun getS() = s is considered to be recursive here :(
// It's a question to be discussed in Dec 2019. Muted at this moment.
// FILE: lateinit.kt
private
lateinit
var
s
:
String
...
...
compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.fir.kt
已删除
100644 → 0
浏览文件 @
6a1f921a
class
B
{
fun
getA
()
=
a
}
\ No newline at end of file
compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt
浏览文件 @
38922a84
// FIR_IDENTICAL
class
B
{
fun
getA
()
=
<!
UNRESOLVED_REFERENCE
!>
a
<!>
}
\ No newline at end of file
compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/Bases.fir.kt
浏览文件 @
38922a84
...
...
@@ -14,8 +14,8 @@ fun foo(k: KotlinClass2) {
useInt
(
k
.
something2
)
useInt
(
k
.
getSomethingKotlin1
())
useInt
(
k
.
getSomethingKotlin2
())
k
.
somethingKotlin1
k
.
somethingKotlin2
k
.
<!
UNRESOLVED_REFERENCE
!>
somethingKotlin1
<!>
k
.
<!
UNRESOLVED_REFERENCE
!>
somethingKotlin2
<!>
}
fun
useInt
(
i
:
Int
)
{}
...
...
@@ -28,4 +28,4 @@ public class JavaClass1 {
// FILE: JavaClass2.java
public
class
JavaClass2
extends
KotlinClass1
{
public
int
getSomething2
()
{
return
1
;
}
}
\ No newline at end of file
}
compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/Getter.fir.kt
浏览文件 @
38922a84
...
...
@@ -9,7 +9,7 @@ fun foo(javaClass: JavaClass, kotlinClass: KotlinClass) {
javaClass
.
something
=
1
javaClass
.<!
UNRESOLVED_REFERENCE
!>
Something
<
!
>
useInt
(
kotlinClass
.
getSomething
())
kotlinClass
.
something
kotlinClass
.
<!
UNRESOLVED_REFERENCE
!>
something
<!>
}
fun
useInt
(
i
:
Int
)
{}
...
...
@@ -17,4 +17,4 @@ fun useInt(i: Int) {}
// FILE: JavaClass.java
public
class
JavaClass
{
public
int
getSomething
()
{
return
1
;
}
}
\ No newline at end of file
}
compiler/testData/diagnostics/tests/syntheticExtensions/javaProperties/KotlinOverridesJava.fir.kt
浏览文件 @
38922a84
...
...
@@ -22,9 +22,9 @@ fun foo(k: KotlinClass) {
useString
(
k
.
something3
)
k
.
setSomething4
(
""
)
k
.
something4
+=
""
k
.
<!
UNRESOLVED_REFERENCE
,
VARIABLE_EXPECTED
!>
something4
<!>
+=
""
k
.<!
INAPPLICABLE_CANDIDATE
!>
setSomething4
<!>(
null
)
k
.
something4
=
null
k
.
<!
UNRESOLVED_REFERENCE
!>
something4
<!>
=
null
useString
(
k
.
getSomething5
())
useString
(
k
.
something5
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录