Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
4a0437a5
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
4a0437a5
编写于
2月 14, 2021
作者:
A
Andrey Zinovyev
提交者:
GitHub
2月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[KAPT] Fix field type correction for delegates (#4107)
#KT-37586 Fixes
上级
bf9fa4c9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
4 deletion
+77
-4
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
...ains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
+16
-4
plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java
...pt3/test/ClassFileToSourceStubConverterTestGenerated.java
+5
-0
plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java
...3/test/IrClassFileToSourceStubConverterTestGenerated.java
+5
-0
plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt
...-compiler/testData/converter/delegateCorrectErrorTypes.kt
+13
-0
plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.txt
...compiler/testData/converter/delegateCorrectErrorTypes.txt
+38
-0
未找到文件。
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
浏览文件 @
4a0437a5
...
...
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.psi.*
import
org.jetbrains.kotlin.resolve.BindingContext
import
org.jetbrains.kotlin.resolve.DelegatingBindingTrace
import
org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import
org.jetbrains.kotlin.resolve.calls.callUtil.getType
import
org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
import
org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
import
org.jetbrains.kotlin.resolve.constants.*
...
...
@@ -704,20 +705,31 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
return
null
}
fun
typeFromAsm
()
=
signatureParser
.
parseFieldSignature
(
field
.
signature
,
treeMaker
.
Type
(
type
))
// Enum type must be an identifier (Javac requirement)
val
typeExpression
=
if
(
isEnum
(
field
.
access
))
val
typeExpression
=
if
(
isEnum
(
field
.
access
))
{
treeMaker
.
SimpleName
(
treeMaker
.
getQualifiedName
(
type
).
substringAfterLast
(
'.'
))
else
}
else
if
(
descriptor
is
PropertyDescriptor
&&
descriptor
.
isDelegated
)
{
getNonErrorType
(
(
descriptor
as
?
CallableDescriptor
)
?.
returnType
,
RETURN_TYPE
,
(
origin
.
element
as
?
KtProperty
)
?.
delegateExpression
?.
getType
(
kaptContext
.
bindingContext
),
RETURN_TYPE
,
ktTypeProvider
=
{
null
},
ifNonError
=
::
typeFromAsm
)
}
else
{
getNonErrorType
(
(
descriptor
as
?
CallableDescriptor
)
?.
returnType
,
RETURN_TYPE
,
ktTypeProvider
=
{
val
fieldOrigin
=
(
kaptContext
.
origins
[
field
]
?.
element
as
?
KtCallableDeclaration
)
?.
takeIf
{
it
!
is
KtFunction
}
fieldOrigin
?.
typeReference
},
ifNonError
=
{
signatureParser
.
parseFieldSignature
(
field
.
signature
,
treeMaker
.
Type
(
type
))
}
ifNonError
=
::
typeFromAsm
)
}
lineMappings
.
registerField
(
containingClass
,
field
)
...
...
plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java
浏览文件 @
4a0437a5
...
...
@@ -119,6 +119,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
runTest
(
"plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt"
);
}
@TestMetadata
(
"delegateCorrectErrorTypes.kt"
)
public
void
testDelegateCorrectErrorTypes
()
throws
Exception
{
runTest
(
"plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt"
);
}
@TestMetadata
(
"deprecated.kt"
)
public
void
testDeprecated
()
throws
Exception
{
runTest
(
"plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt"
);
...
...
plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java
浏览文件 @
4a0437a5
...
...
@@ -120,6 +120,11 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
runTest
(
"plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt"
);
}
@TestMetadata
(
"delegateCorrectErrorTypes.kt"
)
public
void
testDelegateCorrectErrorTypes
()
throws
Exception
{
runTest
(
"plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt"
);
}
@TestMetadata
(
"deprecated.kt"
)
public
void
testDeprecated
()
throws
Exception
{
runTest
(
"plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt"
);
...
...
plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt
0 → 100644
浏览文件 @
4a0437a5
// CORRECT_ERROR_TYPES
@
file
:
Suppress
(
"UNRESOLVED_REFERENCE"
)
package
test
class
Delegate
{
operator
fun
getValue
(
thisRef
:
Any
,
property
:
KProperty
<
*
>):
Any
{
return
Any
()}
}
class
Bar
(
delegate
:
Delegate
)
{
private
val
unknown
:
Unknown
by
delegate
}
plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.txt
0 → 100644
浏览文件 @
4a0437a5
package test;
import java.lang.System;
@kotlin.Metadata()
public final class Bar {
private final test.Delegate unknown$delegate = null;
public Bar(@org.jetbrains.annotations.NotNull()
test.Delegate delegate) {
super();
}
private final Unknown getUnknown() {
return null;
}
}
////////////////////
package test;
import java.lang.System;
@kotlin.Metadata()
public final class Delegate {
public Delegate() {
super();
}
@org.jetbrains.annotations.NotNull()
public final java.lang.Object getValue(@org.jetbrains.annotations.NotNull()
java.lang.Object thisRef, @org.jetbrains.annotations.NotNull()
KProperty<?> property) {
return null;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录