Move SAM adapters from static scope to synthetic one

This commit is contained in:
Mikhail Zarechenskiy
2017-05-02 14:25:48 +03:00
parent 2ff28ebced
commit 95ede7fb67
37 changed files with 281 additions and 45 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS
protected abstract fun computeMemberIndex(): DeclaredMemberIndex
// Fake overrides, SAM constructors/adapters, values()/valueOf(), etc.
// Fake overrides, values()/valueOf(), etc.
protected abstract fun computeNonDeclaredFunctions(result: MutableCollection<SimpleFunctionDescriptor>, name: Name)
protected abstract fun getDispatchReceiverParameter(): ReceiverParameterDescriptor?
@@ -82,9 +82,6 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS
c.components.javaResolverCache.recordMethod(method, descriptor)
result.add(descriptor)
if (method.isStatic) {
result.addIfNotNull(c.components.samConversionResolver.resolveSamAdapter(descriptor))
}
}
result.retainMostSpecificInEachOverridableGroup()
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@ interface SyntheticScope {
fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
fun getSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
fun getSyntheticStaticFunctions(scope: ResolutionScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
fun getSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
}
@@ -46,6 +48,9 @@ fun SyntheticScopes.collectSyntheticExtensionProperties(receiverTypes: Collectio
fun SyntheticScopes.collectSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
= scopes.flatMap { it.getSyntheticMemberFunctions(receiverTypes, name, location) }
fun SyntheticScopes.collectSyntheticStaticFunctions(scope: ResolutionScope, name: Name, location: LookupLocation)
= scopes.flatMap { it.getSyntheticStaticFunctions(scope, name, location) }
fun SyntheticScopes.collectSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>)
= scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) }