Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
24948a8b
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,发现更多精彩内容 >>
提交
24948a8b
编写于
6月 11, 2020
作者:
D
Denis Zharkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FIR: Fix incorrect handling bare types when subject is type alias
^KT-39043 Fixed
上级
063c973e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
105 addition
and
3 deletion
+105
-3
compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.kt
...-tests/testData/resolve/types/bareWithSubjectTypeAlias.kt
+14
-0
compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.txt
...tests/testData/resolve/types/bareWithSubjectTypeAlias.txt
+39
-0
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java
...org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java
+18
-0
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java
.../kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java
+18
-0
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt
...olve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt
+13
-1
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt
...sformers/body/resolve/FirExpressionsResolveTransformer.kt
+3
-2
未找到文件。
compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.kt
0 → 100644
浏览文件 @
24948a8b
sealed
class
A
<
out
T
>
{
class
B
<
out
T1
>(
val
x
:
T1
)
:
A
<
T1
>()
class
C
<
out
T2
>(
val
y
:
T2
)
:
A
<
T2
>()
}
typealias
TA
=
A
<
CharSequence
>
fun
bar
():
TA
=
TODO
()
fun
foo
()
{
when
(
val
a
=
bar
())
{
is
A
.
B
->
a
.
x
.
length
}
}
compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.txt
0 → 100644
浏览文件 @
24948a8b
FILE: bareWithSubjectTypeAlias.kt
public sealed class A<out T> : R|kotlin/Any| {
private constructor<out T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public final class B<out T1> : R|A<T1>| {
public constructor<out T1>(x: R|T1|): R|A.B<T1>| {
super<R|A<T1>|>()
}
public final val x: R|T1| = R|<local>/x|
public get(): R|T1|
}
public final class C<out T2> : R|A<T2>| {
public constructor<out T2>(y: R|T2|): R|A.C<T2>| {
super<R|A<T2>|>()
}
public final val y: R|T2| = R|<local>/y|
public get(): R|T2|
}
}
public final typealias TA = R|A<kotlin/CharSequence>|
public final fun bar(): R|TA| {
^bar R|kotlin/TODO|()
}
public final fun foo(): R|kotlin/Unit| {
when (lval a: R|TA| = R|/bar|()) {
($subj$ is R|A.B<kotlin/CharSequence>|) -> {
R|<local>/a|.R|FakeOverride</A.B.x: R|kotlin/CharSequence|>|.R|kotlin/CharSequence.length|
}
}
}
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java
浏览文件 @
24948a8b
...
...
@@ -2241,6 +2241,24 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
}
}
@TestMetadata
(
"compiler/fir/analysis-tests/testData/resolve/types"
)
@TestDataPath
(
"$PROJECT_ROOT"
)
@RunWith
(
JUnit3RunnerWithInners
.
class
)
public
static
class
Types
extends
AbstractFirDiagnosticsTest
{
private
void
runTest
(
String
testDataFilePath
)
throws
Exception
{
KotlinTestUtils
.
runTest
(
this
::
doTest
,
this
,
testDataFilePath
);
}
public
void
testAllFilesPresentInTypes
()
throws
Exception
{
KotlinTestUtils
.
assertAllTestsPresentByMetadataWithExcluded
(
this
.
getClass
(),
new
File
(
"compiler/fir/analysis-tests/testData/resolve/types"
),
Pattern
.
compile
(
"^([^.]+)\\.kt$"
),
null
,
true
);
}
@TestMetadata
(
"bareWithSubjectTypeAlias.kt"
)
public
void
testBareWithSubjectTypeAlias
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.kt"
);
}
}
@TestMetadata
(
"compiler/fir/analysis-tests/testData/resolve/visibility"
)
@TestDataPath
(
"$PROJECT_ROOT"
)
@RunWith
(
JUnit3RunnerWithInners
.
class
)
...
...
compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java
浏览文件 @
24948a8b
...
...
@@ -2241,6 +2241,24 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
}
}
@TestMetadata
(
"compiler/fir/analysis-tests/testData/resolve/types"
)
@TestDataPath
(
"$PROJECT_ROOT"
)
@RunWith
(
JUnit3RunnerWithInners
.
class
)
public
static
class
Types
extends
AbstractFirDiagnosticsWithLightTreeTest
{
private
void
runTest
(
String
testDataFilePath
)
throws
Exception
{
KotlinTestUtils
.
runTest
(
this
::
doTest
,
this
,
testDataFilePath
);
}
public
void
testAllFilesPresentInTypes
()
throws
Exception
{
KotlinTestUtils
.
assertAllTestsPresentByMetadataWithExcluded
(
this
.
getClass
(),
new
File
(
"compiler/fir/analysis-tests/testData/resolve/types"
),
Pattern
.
compile
(
"^([^.]+)\\.kt$"
),
null
,
true
);
}
@TestMetadata
(
"bareWithSubjectTypeAlias.kt"
)
public
void
testBareWithSubjectTypeAlias
()
throws
Exception
{
runTest
(
"compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.kt"
);
}
}
@TestMetadata
(
"compiler/fir/analysis-tests/testData/resolve/visibility"
)
@TestDataPath
(
"$PROJECT_ROOT"
)
@RunWith
(
JUnit3RunnerWithInners
.
class
)
...
...
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt
浏览文件 @
24948a8b
...
...
@@ -8,13 +8,15 @@ package org.jetbrains.kotlin.fir.resolve
import
org.jetbrains.kotlin.builtins.KotlinBuiltIns
import
org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import
org.jetbrains.kotlin.descriptors.ClassKind
import
org.jetbrains.kotlin.fir.*
import
org.jetbrains.kotlin.fir.FirSession
import
org.jetbrains.kotlin.fir.FirSourceElement
import
org.jetbrains.kotlin.fir.declarations.*
import
org.jetbrains.kotlin.fir.diagnostics.ConeStubDiagnostic
import
org.jetbrains.kotlin.fir.expressions.*
import
org.jetbrains.kotlin.fir.expressions.builder.FirResolvedReifiedParameterReferenceBuilder
import
org.jetbrains.kotlin.fir.expressions.builder.buildExpressionWithSmartcast
import
org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier
import
org.jetbrains.kotlin.fir.inferenceContext
import
org.jetbrains.kotlin.fir.references.FirErrorNamedReference
import
org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import
org.jetbrains.kotlin.fir.references.FirSuperReference
...
...
@@ -28,6 +30,7 @@ import org.jetbrains.kotlin.fir.resolve.providers.bindSymbolToLookupTag
import
org.jetbrains.kotlin.fir.resolve.providers.getSymbolByTypeRef
import
org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
import
org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
import
org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
import
org.jetbrains.kotlin.fir.scopes.impl.FirDeclaredMemberScopeProvider
import
org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
import
org.jetbrains.kotlin.fir.symbols.*
...
...
@@ -87,6 +90,15 @@ fun ConeClassLikeType.fullyExpandedType(
return
fullyExpandedTypeNoCache
(
useSiteSession
,
expandedConeType
)
}
fun
ConeKotlinType
.
fullyExpandedType
(
useSiteSession
:
FirSession
):
ConeKotlinType
=
when
(
this
)
{
is
ConeFlexibleType
->
ConeFlexibleType
(
lowerBound
.
fullyExpandedType
(
useSiteSession
),
upperBound
.
fullyExpandedType
(
useSiteSession
))
is
ConeClassLikeType
->
fullyExpandedType
(
useSiteSession
)
else
->
this
}
private
fun
ConeClassLikeType
.
fullyExpandedTypeNoCache
(
useSiteSession
:
FirSession
,
expandedConeType
:
(
FirTypeAlias
)
->
ConeClassLikeType
?,
...
...
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt
浏览文件 @
24948a8b
...
...
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import
org.jetbrains.kotlin.fir.types.*
import
org.jetbrains.kotlin.fir.types.builder.*
import
org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl
import
org.jetbrains.kotlin.fir.visitors.*
import
org.jetbrains.kotlin.name.ClassId
import
org.jetbrains.kotlin.name.Name
...
...
@@ -379,7 +378,9 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
}
private
fun
FirTypeRef
.
withTypeArgumentsForBareType
(
argument
:
FirExpression
):
FirTypeRef
{
val
baseTypeArguments
=
argument
.
typeRef
.
coneTypeSafe
<
ConeKotlinType
>()
?.
typeArguments
// TODO: Everything should also work for case of checked-type itself is a type alias
val
baseTypeArguments
=
argument
.
typeRef
.
coneTypeSafe
<
ConeKotlinType
>()
?.
fullyExpandedType
(
session
)
?.
typeArguments
val
type
=
coneTypeSafe
<
ConeKotlinType
>()
return
if
(
type
?.
typeArguments
?.
isEmpty
()
!=
true
||
type
is
ConeTypeParameterType
||
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录