Frontend plugins to upstream

Change-Id: Id9203c92d0a711e4f21565bd225a465bd41db476
This commit is contained in:
Jim
2019-09-26 17:03:11 -07:00
committed by Stanislav Erokhin
parent 4878c7967a
commit 267287118b
15 changed files with 267 additions and 29 deletions
@@ -16,9 +16,7 @@
package org.jetbrains.kotlin.resolve.calls.tower
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.model.DiagnosticReporter
@@ -45,6 +43,13 @@ interface ImplicitScopeTower {
val isNewInferenceEnabled: Boolean
val typeApproximator: TypeApproximator
fun interceptCandidates(
resolutionScope: ResolutionScope,
name: Name,
initialResults: Collection<FunctionDescriptor>,
location: LookupLocation
): Collection<FunctionDescriptor>
}
interface ScopeTowerLevel {
@@ -17,6 +17,9 @@
package org.jetbrains.kotlin.resolve.calls.tower
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
@@ -207,7 +210,7 @@ internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qual
.getContributedFunctionsAndConstructors(
name,
location,
scopeTower.syntheticScopes
scopeTower
).map {
createCandidateDescriptor(it, dispatchReceiver = null)
}
@@ -255,7 +258,7 @@ internal open class ScopeBasedTowerLevel protected constructor(
): Collection<CandidateWithBoundDispatchReceiver> {
val result: ArrayList<CandidateWithBoundDispatchReceiver> = ArrayList()
resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticScopes).mapTo(result) {
resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower).mapTo(result) {
createCandidateDescriptor(
it,
dispatchReceiver = null,
@@ -366,7 +369,7 @@ private fun KotlinType?.getInnerConstructors(name: Name, location: LookupLocatio
private fun ResolutionScope.getContributedFunctionsAndConstructors(
name: Name,
location: LookupLocation,
syntheticScopes: SyntheticScopes
scopeTower: ImplicitScopeTower
): Collection<FunctionDescriptor> {
val result = ArrayList<FunctionDescriptor>(getContributedFunctions(name, location))
@@ -374,10 +377,10 @@ private fun ResolutionScope.getContributedFunctionsAndConstructors(
result.addAll(getConstructorsOfClassifier(it))
}
result.addAll(syntheticScopes.collectSyntheticStaticFunctions(this, name, location))
result.addAll(syntheticScopes.collectSyntheticConstructors(this, name, location))
result.addAll(scopeTower.syntheticScopes.collectSyntheticStaticFunctions(this, name, location))
result.addAll(scopeTower.syntheticScopes.collectSyntheticConstructors(this, name, location))
return result.toList()
return scopeTower.interceptCandidates(this, name, result, location).toList()
}
private fun getConstructorsOfClassifier(classifier: ClassifierDescriptor?): List<ConstructorDescriptor> {