Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
490ef210
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,发现更多精彩内容 >>
提交
490ef210
编写于
2月 04, 2021
作者:
D
Dmitriy Novozhilov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIR] Support sealed class inheritors in multiple files
上级
c8f9cc33
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
115 addition
and
141 deletion
+115
-141
compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt
...sis-tests/testData/resolve/diagnostics/sealedSupertype.kt
+1
-1
compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSealedSupertypeChecker.kt
...nalysis/checkers/declaration/FirSealedSupertypeChecker.kt
+8
-35
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt
...olve/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt
+17
-10
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirLegacySealedClassInheritorsTransformer.kt
...transformers/FirLegacySealedClassInheritorsTransformer.kt
+38
-0
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSealedClassInheritorsProcessor.kt
...resolve/transformers/FirSealedClassInheritorsProcessor.kt
+37
-42
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ResolvePhaseUtils.kt
...ains/kotlin/fir/resolve/transformers/ResolvePhaseUtils.kt
+2
-2
compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt
...iler/testData/codegen/box/sealed/multipleFiles_enabled.kt
+0
-1
compiler/testData/diagnostics/tests/sealed/DerivedTopLevel.fir.kt
.../testData/diagnostics/tests/sealed/DerivedTopLevel.fir.kt
+1
-1
compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.fir.kt
...ata/diagnostics/tests/sealed/ExhaustiveWithFreedom.fir.kt
+3
-3
compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt
...ata/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt
+6
-6
compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.fir.kt
...stics/tests/sealed/NestedSealedWithoutRestrictions.fir.kt
+0
-39
compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt
...agnostics/tests/sealed/NestedSealedWithoutRestrictions.kt
+1
-0
compiler/testData/diagnostics/tests/sealed/NeverDerivedFromNested.fir.kt
...ta/diagnostics/tests/sealed/NeverDerivedFromNested.fir.kt
+1
-1
未找到文件。
compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt
浏览文件 @
490ef210
...
@@ -29,7 +29,7 @@ sealed class P {
...
@@ -29,7 +29,7 @@ sealed class P {
class
K
:
P
()
class
K
:
P
()
<!
REDECLARATION
!>
object
B
<!>
{
<!
REDECLARATION
!>
object
B
<!>
{
class
I
:
<!
SEALED_SUPERTYPE
!>
P
<
!
>
()
class
I
:
P
()
}
}
fun
test
()
{
fun
test
()
{
...
...
compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSealedSupertypeChecker.kt
浏览文件 @
490ef210
...
@@ -20,26 +20,18 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
...
@@ -20,26 +20,18 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
override
fun
check
(
declaration
:
FirMemberDeclaration
,
context
:
CheckerContext
,
reporter
:
DiagnosticReporter
)
{
override
fun
check
(
declaration
:
FirMemberDeclaration
,
context
:
CheckerContext
,
reporter
:
DiagnosticReporter
)
{
if
(
declaration
is
FirClass
<
*
>)
{
if
(
declaration
is
FirClass
<
*
>)
{
// only the file declaration is present
// only the file declaration is present
when
{
if
(
declaration
.
classId
.
isLocal
)
{
context
.
containingDeclarations
.
size
==
1
->
{
checkTopLevelDeclaration
(
declaration
,
context
,
reporter
)
}
declaration
.
classId
.
isLocal
->
{
checkLocalDeclaration
(
declaration
,
context
,
reporter
)
checkLocalDeclaration
(
declaration
,
context
,
reporter
)
}
}
else
{
else
->
{
checkGlobalDeclaration
(
declaration
,
context
,
reporter
)
checkInnerDeclaration
(
declaration
,
context
,
reporter
)
}
}
}
}
else
if
(
declaration
is
FirProperty
)
{
}
else
if
(
declaration
is
FirProperty
)
{
val
initializer
=
declaration
.
initializer
.
safeAs
<
FirClass
<
*
>>()
val
initializer
=
declaration
.
initializer
.
safeAs
<
FirClass
<
*
>>()
?:
return
?:
return
checkLocalDeclaration
(
initializer
,
context
,
reporter
)
checkLocalDeclaration
(
initializer
,
context
,
reporter
)
}
}
}
}
private
fun
check
TopLeve
lDeclaration
(
declaration
:
FirClass
<
*
>,
context
:
CheckerContext
,
reporter
:
DiagnosticReporter
)
{
private
fun
check
Globa
lDeclaration
(
declaration
:
FirClass
<
*
>,
context
:
CheckerContext
,
reporter
:
DiagnosticReporter
)
{
for
(
it
in
declaration
.
superTypeRefs
)
{
for
(
it
in
declaration
.
superTypeRefs
)
{
val
classId
=
it
.
coneType
.
classId
?:
continue
val
classId
=
it
.
coneType
.
classId
?:
continue
...
@@ -51,9 +43,9 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
...
@@ -51,9 +43,9 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
?.
fir
.
safeAs
<
FirRegularClass
>()
?.
fir
.
safeAs
<
FirRegularClass
>()
?:
continue
?:
continue
if
(
fir
.
status
.
modality
==
Modality
.
SEALED
&&
classId
.
outerClassId
!=
null
)
{
if
(
fir
.
status
.
modality
==
Modality
.
SEALED
&&
declaration
.
classId
.
packageFqName
!=
fir
.
classId
.
packageFqName
)
{
reporter
.
reportOn
(
it
.
source
,
FirErrors
.
SEALED_SUPERTYPE
,
context
)
reporter
.
reportOn
(
it
.
source
,
FirErrors
.
SEALED_SUPERTYPE
,
context
)
return
continue
}
}
}
}
}
}
...
@@ -76,23 +68,4 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
...
@@ -76,23 +68,4 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
}
}
}
}
}
}
private
fun
checkInnerDeclaration
(
declaration
:
FirClass
<
*
>,
context
:
CheckerContext
,
reporter
:
DiagnosticReporter
)
{
for
(
it
in
declaration
.
superTypeRefs
)
{
val
classId
=
it
.
coneType
.
classId
?:
continue
if
(
classId
.
isLocal
)
{
continue
}
val
fir
=
context
.
session
.
symbolProvider
.
getClassLikeSymbolByFqName
(
classId
)
?.
fir
.
safeAs
<
FirRegularClass
>()
?:
continue
if
(
fir
.
status
.
modality
==
Modality
.
SEALED
&&
!
context
.
containingDeclarations
.
contains
(
fir
))
{
reporter
.
reportOn
(
it
.
source
,
FirErrors
.
SEALED_SUPERTYPE
,
context
)
return
}
}
}
}
}
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt
浏览文件 @
490ef210
...
@@ -65,7 +65,8 @@ abstract class FirVisibilityChecker : FirSessionComponent {
...
@@ -65,7 +65,8 @@ abstract class FirVisibilityChecker : FirSessionComponent {
Visibilities
.
Private
,
Visibilities
.
PrivateToThis
->
{
Visibilities
.
Private
,
Visibilities
.
PrivateToThis
->
{
val
ownerId
=
symbol
.
getOwnerId
()
val
ownerId
=
symbol
.
getOwnerId
()
if
(
declaration
.
session
==
session
)
{
if
(
declaration
.
session
==
session
)
{
if
(
ownerId
==
null
||
declaration
is
FirConstructor
&&
declaration
.
isFromSealedClass
)
{
when
{
ownerId
==
null
->
{
val
candidateFile
=
when
(
symbol
)
{
val
candidateFile
=
when
(
symbol
)
{
is
FirClassLikeSymbol
<
*
>
->
provider
.
getFirClassifierContainerFileIfAny
(
symbol
)
is
FirClassLikeSymbol
<
*
>
->
provider
.
getFirClassifierContainerFileIfAny
(
symbol
)
is
FirCallableSymbol
<
*
>
->
provider
.
getFirCallableContainerFile
(
symbol
)
is
FirCallableSymbol
<
*
>
->
provider
.
getFirCallableContainerFile
(
symbol
)
...
@@ -73,10 +74,16 @@ abstract class FirVisibilityChecker : FirSessionComponent {
...
@@ -73,10 +74,16 @@ abstract class FirVisibilityChecker : FirSessionComponent {
}
}
// Top-level: visible in file
// Top-level: visible in file
candidateFile
==
useSiteFile
candidateFile
==
useSiteFile
}
else
{
}
declaration
is
FirConstructor
&&
declaration
.
isFromSealedClass
->
{
// Sealed class constructor: visible in same package
declaration
.
symbol
.
callableId
.
packageName
==
useSiteFile
.
packageFqName
}
else
->
{
// Member: visible inside parent class, including all its member classes
// Member: visible inside parent class, including all its member classes
canSeePrivateMemberOf
(
containingDeclarations
,
ownerId
,
session
)
canSeePrivateMemberOf
(
containingDeclarations
,
ownerId
,
session
)
}
}
}
}
else
{
}
else
{
declaration
is
FirSimpleFunction
&&
declaration
.
isAllowedToBeAccessedFromOutside
()
declaration
is
FirSimpleFunction
&&
declaration
.
isAllowedToBeAccessedFromOutside
()
}
}
...
...
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirLegacySealedClassInheritorsTransformer.kt
0 → 100644
浏览文件 @
490ef210
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package
org.jetbrains.kotlin.fir.resolve.transformers
import
org.jetbrains.kotlin.fir.FirElement
import
org.jetbrains.kotlin.fir.FirSession
import
org.jetbrains.kotlin.fir.declarations.FirDeclaration
import
org.jetbrains.kotlin.fir.declarations.FirFile
import
org.jetbrains.kotlin.fir.declarations.FirRegularClass
import
org.jetbrains.kotlin.fir.resolve.ScopeSession
import
org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
import
org.jetbrains.kotlin.fir.visitors.FirTransformer
import
org.jetbrains.kotlin.fir.visitors.compose
import
org.jetbrains.kotlin.name.ClassId
/*
* This processor is needed only for IDE until there won't be proper IDE implementation
* for detecting sealed inheritors in multiple files
*/
class
FirLegacySealedClassInheritorsProcessor
(
session
:
FirSession
,
scopeSession
:
ScopeSession
)
:
FirTransformerBasedResolveProcessor
(
session
,
scopeSession
)
{
override
val
transformer
=
FirLegacySealedClassInheritorsTransformer
()
}
class
FirLegacySealedClassInheritorsTransformer
:
FirTransformer
<
Nothing
?
>()
{
override
fun
<
E
:
FirElement
>
transformElement
(
element
:
E
,
data
:
Nothing
?):
CompositeTransformResult
<
E
>
{
throw
IllegalStateException
(
"Should not be there"
)
}
override
fun
transformFile
(
file
:
FirFile
,
data
:
Nothing
?):
CompositeTransformResult
<
FirDeclaration
>
{
val
sealedClassInheritorsMap
=
mutableMapOf
<
FirRegularClass
,
MutableList
<
ClassId
>>()
file
.
accept
(
FirSealedClassInheritorsProcessor
.
InheritorsCollector
,
sealedClassInheritorsMap
)
if
(
sealedClassInheritorsMap
.
isEmpty
())
return
file
.
compose
()
return
file
.
transform
(
FirSealedClassInheritorsProcessor
.
InheritorsTransformer
(
sealedClassInheritorsMap
),
null
)
}
}
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSealedClassInheritors
Transforme
r.kt
→
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSealedClassInheritors
Processo
r.kt
浏览文件 @
490ef210
/*
/*
* Copyright 2010-20
19
JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-20
21
JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
*/
...
@@ -11,59 +11,30 @@ import org.jetbrains.kotlin.fir.FirSession
...
@@ -11,59 +11,30 @@ import org.jetbrains.kotlin.fir.FirSession
import
org.jetbrains.kotlin.fir.declarations.*
import
org.jetbrains.kotlin.fir.declarations.*
import
org.jetbrains.kotlin.fir.expressions.FirStatement
import
org.jetbrains.kotlin.fir.expressions.FirStatement
import
org.jetbrains.kotlin.fir.resolve.ScopeSession
import
org.jetbrains.kotlin.fir.resolve.ScopeSession
import
org.jetbrains.kotlin.fir.resolve.symbolProvider
import
org.jetbrains.kotlin.fir.resolve.firProvider
import
org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
import
org.jetbrains.kotlin.fir.resolve.getSymbolByLookupTag
import
org.jetbrains.kotlin.fir.resolve.getSymbolByLookupTag
import
org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
import
org.jetbrains.kotlin.fir.resolve.symbolProvider
import
org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
import
org.jetbrains.kotlin.fir.types.ConeLookupTagBasedType
import
org.jetbrains.kotlin.fir.types.ConeLookupTagBasedType
import
org.jetbrains.kotlin.fir.types.FirTypeRef
import
org.jetbrains.kotlin.fir.types.FirTypeRef
import
org.jetbrains.kotlin.fir.types.coneType
import
org.jetbrains.kotlin.fir.types.coneType
import
org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
import
org.jetbrains.kotlin.fir.visitors.*
import
org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
import
org.jetbrains.kotlin.fir.visitors.FirTransformer
import
org.jetbrains.kotlin.fir.visitors.compose
import
org.jetbrains.kotlin.name.ClassId
import
org.jetbrains.kotlin.name.ClassId
class
FirSealedClassInheritorsProcessor
(
session
:
FirSession
,
scopeSession
:
ScopeSession
)
:
FirTransformerBasedResolveProcessor
(
session
,
scopeSession
)
{
class
FirSealedClassInheritorsProcessor
(
override
val
transformer
=
FirSealedClassInheritorsTransformer
()
session
:
FirSession
,
}
scopeSession
:
ScopeSession
)
:
FirGlobalResolveProcessor
(
session
,
scopeSession
)
{
class
FirSealedClassInheritorsTransformer
:
FirTransformer
<
Nothing
?
>()
{
override
fun
process
(
files
:
Collection
<
FirFile
>)
{
override
fun
<
E
:
FirElement
>
transformElement
(
element
:
E
,
data
:
Nothing
?):
CompositeTransformResult
<
E
>
{
throw
IllegalStateException
(
"Should not be there"
)
}
override
fun
transformFile
(
file
:
FirFile
,
data
:
Nothing
?):
CompositeTransformResult
<
FirDeclaration
>
{
val
sealedClassInheritorsMap
=
mutableMapOf
<
FirRegularClass
,
MutableList
<
ClassId
>>()
val
sealedClassInheritorsMap
=
mutableMapOf
<
FirRegularClass
,
MutableList
<
ClassId
>>()
file
.
accept
(
InheritorsCollector
,
sealedClassInheritorsMap
)
files
.
forEach
{
it
.
accept
(
InheritorsCollector
,
sealedClassInheritorsMap
)
}
if
(
sealedClassInheritorsMap
.
isEmpty
())
return
file
.
compose
()
files
.
forEach
{
it
.
transformSingle
(
InheritorsTransformer
(
sealedClassInheritorsMap
),
null
)
}
return
file
.
transform
(
InheritorsTransformer
(
sealedClassInheritorsMap
),
null
)
}
private
class
InheritorsTransformer
(
private
val
inheritorsMap
:
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>)
:
FirTransformer
<
Nothing
?
>()
{
override
fun
<
E
:
FirElement
>
transformElement
(
element
:
E
,
data
:
Nothing
?):
CompositeTransformResult
<
E
>
{
return
element
.
compose
()
}
}
override
fun
transformFile
(
file
:
FirFile
,
data
:
Nothing
?):
CompositeTransformResult
<
FirDeclaration
>
{
object
InheritorsCollector
:
FirDefaultVisitor
<
Unit
,
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>>()
{
return
(
file
.
transformChildren
(
this
,
data
)
as
FirFile
).
compose
()
}
override
fun
transformRegularClass
(
regularClass
:
FirRegularClass
,
data
:
Nothing
?):
CompositeTransformResult
<
FirStatement
>
{
if
(
regularClass
.
modality
==
Modality
.
SEALED
)
{
val
inheritors
=
inheritorsMap
.
remove
(
regularClass
)
if
(
inheritors
!=
null
)
{
regularClass
.
sealedInheritors
=
inheritors
}
}
if
(
inheritorsMap
.
isEmpty
())
return
regularClass
.
compose
()
return
(
regularClass
.
transformChildren
(
this
,
data
)
as
FirRegularClass
).
compose
()
}
}
private
object
InheritorsCollector
:
FirDefaultVisitor
<
Unit
,
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>>()
{
override
fun
visitElement
(
element
:
FirElement
,
data
:
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>)
{}
override
fun
visitElement
(
element
:
FirElement
,
data
:
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>)
{}
override
fun
visitFile
(
file
:
FirFile
,
data
:
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>)
{
override
fun
visitFile
(
file
:
FirFile
,
data
:
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>)
{
...
@@ -81,6 +52,8 @@ class FirSealedClassInheritorsTransformer : FirTransformer<Nothing?>() {
...
@@ -81,6 +52,8 @@ class FirSealedClassInheritorsTransformer : FirTransformer<Nothing?>() {
for
(
typeRef
in
regularClass
.
superTypeRefs
)
{
for
(
typeRef
in
regularClass
.
superTypeRefs
)
{
val
parent
=
extractClassFromTypeRef
(
symbolProvider
,
typeRef
).
takeIf
{
it
?.
modality
==
Modality
.
SEALED
}
?:
continue
val
parent
=
extractClassFromTypeRef
(
symbolProvider
,
typeRef
).
takeIf
{
it
?.
modality
==
Modality
.
SEALED
}
?:
continue
// Inheritors of sealed class are allowed only in same package
if
(
parent
.
classId
.
packageFqName
!=
regularClass
.
classId
.
packageFqName
)
continue
val
inheritors
=
data
.
computeIfAbsent
(
parent
)
{
mutableListOf
()
}
val
inheritors
=
data
.
computeIfAbsent
(
parent
)
{
mutableListOf
()
}
inheritors
+=
regularClass
.
symbol
.
classId
inheritors
+=
regularClass
.
symbol
.
classId
}
}
...
@@ -99,6 +72,28 @@ class FirSealedClassInheritorsTransformer : FirTransformer<Nothing?>() {
...
@@ -99,6 +72,28 @@ class FirSealedClassInheritorsTransformer : FirTransformer<Nothing?>() {
}
}
}
}
}
}
class
InheritorsTransformer
(
private
val
inheritorsMap
:
MutableMap
<
FirRegularClass
,
MutableList
<
ClassId
>>)
:
FirTransformer
<
Nothing
?
>()
{
override
fun
<
E
:
FirElement
>
transformElement
(
element
:
E
,
data
:
Nothing
?):
CompositeTransformResult
<
E
>
{
return
element
.
compose
()
}
override
fun
transformFile
(
file
:
FirFile
,
data
:
Nothing
?):
CompositeTransformResult
<
FirDeclaration
>
{
return
(
file
.
transformChildren
(
this
,
data
)
as
FirFile
).
compose
()
}
override
fun
transformRegularClass
(
regularClass
:
FirRegularClass
,
data
:
Nothing
?):
CompositeTransformResult
<
FirStatement
>
{
if
(
regularClass
.
modality
==
Modality
.
SEALED
)
{
val
inheritors
=
inheritorsMap
.
remove
(
regularClass
)
if
(
inheritors
!=
null
)
{
regularClass
.
sealedInheritors
=
inheritors
}
}
if
(
inheritorsMap
.
isEmpty
())
return
regularClass
.
compose
()
return
(
regularClass
.
transformChildren
(
this
,
data
)
as
FirRegularClass
).
compose
()
}
}
}
}
object
SealedClassInheritorsKey
:
FirDeclarationDataKey
()
object
SealedClassInheritorsKey
:
FirDeclarationDataKey
()
...
...
compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ResolvePhaseUtils.kt
浏览文件 @
490ef210
...
@@ -50,7 +50,7 @@ fun FirResolvePhase.createTransformerBasedProcessorByPhase(
...
@@ -50,7 +50,7 @@ fun FirResolvePhase.createTransformerBasedProcessorByPhase(
CLASS_GENERATION
->
FirDummyTransformerBasedProcessor
(
session
,
scopeSession
)
// TODO: remove
CLASS_GENERATION
->
FirDummyTransformerBasedProcessor
(
session
,
scopeSession
)
// TODO: remove
IMPORTS
->
FirImportResolveProcessor
(
session
,
scopeSession
)
IMPORTS
->
FirImportResolveProcessor
(
session
,
scopeSession
)
SUPER_TYPES
->
FirSupertypeResolverProcessor
(
session
,
scopeSession
)
SUPER_TYPES
->
FirSupertypeResolverProcessor
(
session
,
scopeSession
)
SEALED_CLASS_INHERITORS
->
FirSealedClassInheritorsProcessor
(
session
,
scopeSession
)
SEALED_CLASS_INHERITORS
->
Fir
Legacy
SealedClassInheritorsProcessor
(
session
,
scopeSession
)
TYPES
->
FirTypeResolveProcessor
(
session
,
scopeSession
)
TYPES
->
FirTypeResolveProcessor
(
session
,
scopeSession
)
ARGUMENTS_OF_PLUGIN_ANNOTATIONS
->
FirAnnotationArgumentsResolveProcessor
(
session
,
scopeSession
)
ARGUMENTS_OF_PLUGIN_ANNOTATIONS
->
FirAnnotationArgumentsResolveProcessor
(
session
,
scopeSession
)
EXTENSION_STATUS_UPDATE
->
FirTransformerBasedExtensionStatusProcessor
(
session
,
scopeSession
)
EXTENSION_STATUS_UPDATE
->
FirTransformerBasedExtensionStatusProcessor
(
session
,
scopeSession
)
...
...
compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt
浏览文件 @
490ef210
// ISSUE: KT-13495
// ISSUE: KT-13495
// IGNORE_BACKEND_FIR: JVM_IR
// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage
// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage
// FILE: Base.kt
// FILE: Base.kt
...
...
compiler/testData/diagnostics/tests/sealed/DerivedTopLevel.fir.kt
浏览文件 @
490ef210
sealed
class
Base
sealed
class
Base
class
Derived
:
Base
()
{
class
Derived
:
Base
()
{
class
Derived2
:
<!
SEALED_SUPERTYPE
!>
Base
<
!
>
()
class
Derived2
:
Base
()
}
}
fun
test
()
{
fun
test
()
{
...
...
compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.fir.kt
浏览文件 @
490ef210
...
@@ -10,14 +10,14 @@ sealed class Base {
...
@@ -10,14 +10,14 @@ sealed class Base {
// FILE: B.kt
// FILE: B.kt
class
B
:
<!
HIDDEN
!>
Base
<
!
>
()
class
B
:
Base
()
// FILE: Container.kt
// FILE: Container.kt
class
Containter
{
class
Containter
{
class
C
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Base
<
!
>
()
class
C
:
Base
()
inner
class
D
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Base
<
!
>
()
inner
class
D
:
Base
()
}
}
// FILE: main.kt
// FILE: main.kt
...
...
compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt
浏览文件 @
490ef210
...
@@ -13,21 +13,21 @@ sealed class Base {
...
@@ -13,21 +13,21 @@ sealed class Base {
package
foo
package
foo
class
B
:
<!
HIDDEN
!>
Base
<
!
>
()
class
B
:
Base
()
// FILE: c.kt
// FILE: c.kt
package
foo
package
foo
class
Container
{
class
Container
{
class
C
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Base
<
!
>
()
class
C
:
Base
()
inner
class
D
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Base
<
!
>
()
inner
class
D
:
Base
()
val
anon
=
object
: <!
HIDDEN
,
SEALED_SUPERTYPE_IN_LOCAL_CLASS
!>
Base
<
!
>()
{}
// Should be an error
val
anon
=
object
: <!
SEALED_SUPERTYPE_IN_LOCAL_CLASS
!>
Base
<
!
>()
{}
// Should be an error
fun
someFun
()
{
fun
someFun
()
{
class
LocalClass
:
<!
HIDDEN
,
SEALED_SUPERTYPE_IN_LOCAL_CLASS
!>
Base
<
!
>()
{}
// Should be an error
class
LocalClass
:
<!
SEALED_SUPERTYPE_IN_LOCAL_CLASS
!>
Base
<
!
>()
{}
// Should be an error
}
}
}
}
...
@@ -37,4 +37,4 @@ package bar
...
@@ -37,4 +37,4 @@ package bar
import
foo.Base
import
foo.Base
class
E
:
<!
HIDDEN
!>
Base
<
!
>()
class
E
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Base
<
!
>()
compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.fir.kt
已删除
100644 → 0
浏览文件 @
c8f9cc33
// ISSUE: KT-13495
// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: base.kt
package
foo
class
Container
{
sealed
class
Base
}
// FILE: a.kt
package
foo
class
A
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Container
.
Base
<
!
>()
// FILE: b.kt
package
foo
class
BContainer
{
class
B
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Container
.
Base
<
!
>()
inner
class
C
:
<!
HIDDEN
,
SEALED_SUPERTYPE
!>
Container
.
Base
<
!
>()
}
// FILE: test.kt
package
foo
fun
test
(
base
:
Container
.
Base
)
{
val
x
=
when
(
base
)
{
is
A
->
1
is
BContainer
.
B
->
2
is
BContainer
.
C
->
3
}
}
compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt
浏览文件 @
490ef210
// FIR_IDENTICAL
// ISSUE: KT-13495
// ISSUE: KT-13495
// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage
// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage
// !DIAGNOSTICS: -UNUSED_VARIABLE
// !DIAGNOSTICS: -UNUSED_VARIABLE
...
...
compiler/testData/diagnostics/tests/sealed/NeverDerivedFromNested.fir.kt
浏览文件 @
490ef210
...
@@ -2,7 +2,7 @@ class A {
...
@@ -2,7 +2,7 @@ class A {
sealed
class
Base
sealed
class
Base
}
}
class
Derived
:
<!
SEALED_SUPERTYPE
!>
A
.
Base
<
!
>
()
class
Derived
:
A
.
Base
()
fun
test
()
{
fun
test
()
{
class
DerivedLocal
:
<!
SEALED_SUPERTYPE_IN_LOCAL_CLASS
!>
A
.
Base
<
!
>()
class
DerivedLocal
:
<!
SEALED_SUPERTYPE_IN_LOCAL_CLASS
!>
A
.
Base
<
!
>()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录