FIR: Optimize SupertypeComputationSession::breakLoops
This commit is contained in:
+8
-4
@@ -310,15 +310,18 @@ private class SupertypeComputationSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
supertypeStatusMap[classLikeDeclaration] = SupertypeComputationStatus.Computed(resolvedTypesRefs)
|
supertypeStatusMap[classLikeDeclaration] = SupertypeComputationStatus.Computed(resolvedTypesRefs)
|
||||||
|
newClassifiersForBreakingLoops.add(classLikeDeclaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val newClassifiersForBreakingLoops = mutableListOf<FirClassLikeDeclaration<*>>()
|
||||||
|
private val breakLoopsDfsVisited = hashSetOf<FirClassLikeDeclaration<*>>()
|
||||||
|
|
||||||
fun breakLoops(session: FirSession) {
|
fun breakLoops(session: FirSession) {
|
||||||
val visited = hashSetOf<FirClassLikeDeclaration<*>>()
|
|
||||||
val inProcess = hashSetOf<FirClassLikeDeclaration<*>>()
|
val inProcess = hashSetOf<FirClassLikeDeclaration<*>>()
|
||||||
|
|
||||||
fun dfs(classLikeDeclaration: FirClassLikeDeclaration<*>) {
|
fun dfs(classLikeDeclaration: FirClassLikeDeclaration<*>) {
|
||||||
|
if (classLikeDeclaration in breakLoopsDfsVisited) return
|
||||||
val supertypeComputationStatus = supertypeStatusMap[classLikeDeclaration] ?: return
|
val supertypeComputationStatus = supertypeStatusMap[classLikeDeclaration] ?: return
|
||||||
if (classLikeDeclaration in visited) return
|
|
||||||
if (classLikeDeclaration in inProcess) return
|
if (classLikeDeclaration in inProcess) return
|
||||||
|
|
||||||
inProcess.add(classLikeDeclaration)
|
inProcess.add(classLikeDeclaration)
|
||||||
@@ -351,12 +354,13 @@ private class SupertypeComputationSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inProcess.remove(classLikeDeclaration)
|
inProcess.remove(classLikeDeclaration)
|
||||||
visited.add(classLikeDeclaration)
|
breakLoopsDfsVisited.add(classLikeDeclaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (classifier in supertypeStatusMap.keys) {
|
for (classifier in newClassifiersForBreakingLoops) {
|
||||||
dfs(classifier)
|
dfs(classifier)
|
||||||
}
|
}
|
||||||
|
newClassifiersForBreakingLoops.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-3
@@ -9,8 +9,8 @@ class Foo
|
|||||||
|
|
||||||
class Bar
|
class Bar
|
||||||
|
|
||||||
typealias YBar = ZBar
|
typealias YBar = <!OTHER_ERROR!>ZBar<!>
|
||||||
typealias ZBar = <!OTHER_ERROR!>YBar<!>
|
typealias ZBar = YBar
|
||||||
|
|
||||||
fun Foo.foo(body: Foo.() -> Unit) = body()
|
fun Foo.foo(body: Foo.() -> Unit) = body()
|
||||||
fun Foo.zbar(body: ZBar.() -> Unit) = Bar().body()
|
fun Foo.zbar(body: ZBar.() -> Unit) = Bar().body()
|
||||||
@@ -21,4 +21,4 @@ fun test() {
|
|||||||
foo {}
|
foo {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ typealias R = <!OTHER_ERROR!>R<!>
|
|||||||
|
|
||||||
typealias L = List<L>
|
typealias L = List<L>
|
||||||
|
|
||||||
typealias A = B
|
typealias A = <!OTHER_ERROR!>B<!>
|
||||||
typealias B = <!OTHER_ERROR!>A<!>
|
typealias B = A
|
||||||
|
|
||||||
typealias F1 = (Int) -> F2
|
typealias F1 = (Int) -> F2
|
||||||
typealias F2 = (F1) -> Int
|
typealias F2 = (F1) -> Int
|
||||||
|
|
||||||
val x: A = TODO()
|
val x: A = TODO()
|
||||||
|
|||||||
Reference in New Issue
Block a user