Move SAM adapters from static scope to synthetic one
This commit is contained in:
+5
-5
@@ -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.
|
||||
@@ -29,10 +29,7 @@ import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.collectSyntheticExtensionProperties
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
@@ -180,6 +177,9 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSyntheticStaticFunctions(scope: ResolutionScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= emptyList()
|
||||
|
||||
private fun collectSyntheticPropertiesByName(result: SmartList<PropertyDescriptor>?, type: TypeConstructor, name: Name, processedTypes: MutableSet<TypeConstructor>?, location: LookupLocation): SmartList<PropertyDescriptor>? {
|
||||
if (processedTypes != null && !processedTypes.add(type)) return result
|
||||
|
||||
|
||||
+21
-1
@@ -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.
|
||||
@@ -23,16 +23,20 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.wrapWithCapturingSubstitution
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.findCorrespondingSupertype
|
||||
import java.util.*
|
||||
import kotlin.collections.LinkedHashSet
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
interface SamAdapterExtensionFunctionDescriptor : FunctionDescriptor, SyntheticMemberDescriptor<FunctionDescriptor> {
|
||||
@@ -47,6 +51,11 @@ class SamAdapterFunctionsScope(
|
||||
extensionForFunctionNotCached(function)
|
||||
}
|
||||
|
||||
private val samAdapterForStaticFunction =
|
||||
storageManager.createMemoizedFunctionWithNullableValues<DeclarationDescriptor, SamAdapterDescriptor<JavaMethodDescriptor>> { function ->
|
||||
samAdapterForFunctionNotCached(function)
|
||||
}
|
||||
|
||||
private fun extensionForFunctionNotCached(function: FunctionDescriptor): FunctionDescriptor? {
|
||||
if (!function.visibility.isVisibleOutside()) return null
|
||||
if (!function.hasJavaOriginInHierarchy()) return null //TODO: should we go into base at all?
|
||||
@@ -56,6 +65,13 @@ class SamAdapterFunctionsScope(
|
||||
return MyFunctionDescriptor.create(function)
|
||||
}
|
||||
|
||||
private fun samAdapterForFunctionNotCached(function: DeclarationDescriptor): SamAdapterDescriptor<JavaMethodDescriptor>? {
|
||||
if (function !is JavaMethodDescriptor) return null
|
||||
if (function.dispatchReceiverParameter != null) return null // consider only statics
|
||||
if (!SingleAbstractMethodUtils.isSamAdapterNecessary(function)) return null
|
||||
return SingleAbstractMethodUtils.createSamAdapterFunction(function)
|
||||
}
|
||||
|
||||
override fun getSyntheticMemberFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
var result: SmartList<FunctionDescriptor>? = null
|
||||
for (type in receiverTypes) {
|
||||
@@ -102,6 +118,10 @@ class SamAdapterFunctionsScope(
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> = emptyList()
|
||||
|
||||
override fun getSyntheticStaticFunctions(scope: ResolutionScope, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return scope.getContributedFunctions(name, location).mapNotNull { samAdapterForStaticFunction(it) }
|
||||
}
|
||||
|
||||
private class MyFunctionDescriptor(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
original: SimpleFunctionDescriptor?,
|
||||
|
||||
@@ -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.
|
||||
@@ -161,7 +161,11 @@ internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qual
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?) = qualifier.staticScope
|
||||
.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticConstructorsProvider).map {
|
||||
.getContributedFunctionsAndConstructors(name,
|
||||
location,
|
||||
scopeTower.syntheticConstructorsProvider,
|
||||
scopeTower.syntheticScopes,
|
||||
qualifier.staticScope).map {
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
}
|
||||
}
|
||||
@@ -185,7 +189,11 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?): Collection<CandidateWithBoundDispatchReceiver>
|
||||
= resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticConstructorsProvider).map {
|
||||
= resolutionScope.getContributedFunctionsAndConstructors(name,
|
||||
location,
|
||||
scopeTower.syntheticConstructorsProvider,
|
||||
scopeTower.syntheticScopes,
|
||||
resolutionScope).map {
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
}
|
||||
}
|
||||
@@ -263,7 +271,9 @@ private fun KotlinType?.getInnerConstructors(name: Name, location: LookupLocatio
|
||||
private fun ResolutionScope.getContributedFunctionsAndConstructors(
|
||||
name: Name,
|
||||
location: LookupLocation,
|
||||
syntheticConstructorsProvider: SyntheticConstructorsProvider
|
||||
syntheticConstructorsProvider: SyntheticConstructorsProvider,
|
||||
syntheticScopes: SyntheticScopes,
|
||||
scope: ResolutionScope
|
||||
): Collection<FunctionDescriptor> {
|
||||
val result = ArrayList<FunctionDescriptor>(getContributedFunctions(name, location))
|
||||
|
||||
@@ -273,6 +283,8 @@ private fun ResolutionScope.getContributedFunctionsAndConstructors(
|
||||
syntheticConstructorsProvider.getSyntheticConstructors(classifier, location).filterTo(result) { it.dispatchReceiverParameter == null }
|
||||
}
|
||||
|
||||
result.addAll(syntheticScopes.collectSyntheticStaticFunctions(scope, name, location))
|
||||
|
||||
return result.toList()
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -13,6 +13,5 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun invokeLater(/*0*/ doRun: (() -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun invokeLater(/*0*/ doRun: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun foo(/*0*/ c: (() -> kotlin.Unit)!): kotlin.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun foo(/*0*/ c: java.io.Closeable!): kotlin.Unit
|
||||
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// FILE: Statics.java
|
||||
|
||||
public class Statics {
|
||||
public static void foo(Runnable r) {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class A : Statics() {
|
||||
fun test() {
|
||||
foo {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public final class A : Statics {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class Statics {
|
||||
public constructor Statics()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: a/Statics.java
|
||||
|
||||
package a;
|
||||
|
||||
public class Statics {
|
||||
public static void foo(Runnable r) {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
package b
|
||||
|
||||
import a.Statics.*
|
||||
|
||||
fun test() {
|
||||
foo {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
package b {
|
||||
public fun test(): kotlin.Unit
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: a/Statics.java
|
||||
|
||||
package a;
|
||||
|
||||
public class Statics {
|
||||
public static void foo(Runnable r) {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
package b;
|
||||
|
||||
import a.Statics.foo
|
||||
|
||||
fun test() {
|
||||
foo {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
package b {
|
||||
public fun test(): kotlin.Unit
|
||||
}
|
||||
-2
@@ -11,9 +11,7 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ l: ((x: kotlin.String!) -> kotlin.Any!)!): kotlin.Unit
|
||||
public open fun bar(/*0*/ l: EventListener<*>!): kotlin.Unit
|
||||
public final /*synthesized*/ fun baz(/*0*/ l: ((x: kotlin.String!) -> kotlin.CharSequence!)!): kotlin.Unit
|
||||
public open fun baz(/*0*/ l: EventListener<out kotlin.CharSequence!>!): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -11,9 +11,7 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ l: ((e: kotlin.Any!) -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun bar(/*0*/ l: EventListener<*>!): kotlin.Unit
|
||||
public final /*synthesized*/ fun baz(/*0*/ l: ((e: kotlin.CharSequence!) -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun baz(/*0*/ l: EventListener<out kotlin.CharSequence!>!): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -11,7 +11,6 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ l: ((e: kotlin.String!) -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun bar(/*0*/ l: EventListener<in kotlin.String!>!): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
Vendored
-1
@@ -11,7 +11,6 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ l: ((e: kotlin.collections.(Mutable)Map<kotlin.String!, kotlin.Int!>!) -> kotlin.CharSequence!)!): kotlin.Unit
|
||||
public open fun bar(/*0*/ l: Function<*, *>!): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -10,7 +10,6 @@ package test {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun foo(/*0*/ s: kotlin.String!, /*1*/ r: (() -> kotlin.Unit)!, /*2*/ z: kotlin.Boolean!): kotlin.Unit
|
||||
public open fun foo(/*0*/ s: kotlin.String!, /*1*/ r: java.lang.Runnable!, /*2*/ z: kotlin.Boolean!): kotlin.Unit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,5 @@ public open class B {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ y: ((y: kotlin.String?) -> kotlin.Boolean)!): kotlin.Unit
|
||||
public open fun bar(/*0*/ y: A<kotlin.String!>!): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -33,13 +33,10 @@ public abstract class C {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final override /*1*/ /*fake_override*/ fun </*0*/ T : kotlin.Any!> aStaticMethod(/*0*/ x: T!, /*1*/ y: ((x: T!) -> kotlin.Unit)!): kotlin.Unit
|
||||
public final /*synthesized*/ fun aStaticMethod(/*0*/ x: kotlin.Any!, /*1*/ y: ((x: kotlin.Any!) -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun aStaticMethod(/*0*/ x: kotlin.Any!, /*1*/ y: Fun<(raw) kotlin.Any!>!): kotlin.Unit
|
||||
}
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun </*0*/ T : kotlin.Any!> aStaticMethod(/*0*/ x: T!, /*1*/ y: ((x: T!) -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun </*0*/ T : kotlin.Any!> aStaticMethod(/*0*/ x: T!, /*1*/ y: Fun<T!>!): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
Vendored
-2
@@ -10,10 +10,8 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
|
||||
public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String!
|
||||
public final /*synthesized*/ fun foo(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
|
||||
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String!
|
||||
}
|
||||
|
||||
-2
@@ -10,10 +10,8 @@ public open class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
|
||||
public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String!
|
||||
public final /*synthesized*/ fun foo(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
|
||||
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String!
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: StaticOverrides.java
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
|
||||
public class StaticOverrides {
|
||||
public static class A {
|
||||
public static int foo(Runnable x) { return 0; }
|
||||
public static boolean foo(Function0<Unit> x) { return true; }
|
||||
}
|
||||
|
||||
public static class B {
|
||||
public static String foo(Runnable x) { return ""; }
|
||||
}
|
||||
|
||||
public static class C extends A {
|
||||
public static String foo(Runnable x) { return ""; }
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
StaticOverrides.A.foo {} checkType { _<Boolean>() }
|
||||
StaticOverrides.B.foo {} checkType { _<String>() }
|
||||
StaticOverrides.C.foo {} checkType { _<Boolean>() }
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class StaticOverrides {
|
||||
public constructor StaticOverrides()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun foo(/*0*/ x: (() -> kotlin.Unit!)!): kotlin.Boolean
|
||||
public open fun foo(/*0*/ x: java.lang.Runnable!): kotlin.Int
|
||||
}
|
||||
|
||||
public open class B {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun foo(/*0*/ x: java.lang.Runnable!): kotlin.String!
|
||||
}
|
||||
|
||||
public open class C : StaticOverrides.A {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ x: (() -> kotlin.Unit!)!): kotlin.Boolean
|
||||
public open fun foo(/*0*/ x: java.lang.Runnable!): kotlin.String!
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ public final class DifferentParametersCount {
|
||||
public constructor A()
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ p1: kotlin.Int): kotlin.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: kotlin.Int): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -15,8 +14,6 @@ public final class DifferentParametersCount {
|
||||
public constructor B()
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ p1: kotlin.Int): kotlin.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: kotlin.Int): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package test;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
|
||||
public final class FakeStaticOverrides {
|
||||
public static class A {
|
||||
static public void foo(Function0<Unit> x) {}
|
||||
}
|
||||
|
||||
public static class B extends A {
|
||||
// SAM adapter should not override A.foo
|
||||
static public void foo(Runnable x) {}
|
||||
}
|
||||
|
||||
public static class C extends B {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package test
|
||||
|
||||
public final class FakeStaticOverrides {
|
||||
public constructor FakeStaticOverrides()
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
|
||||
// Static members
|
||||
public open fun foo(/*0*/ p0: (() -> kotlin.Unit!)!): kotlin.Unit
|
||||
}
|
||||
|
||||
public open class B : test.FakeStaticOverrides.A {
|
||||
public constructor B()
|
||||
|
||||
// Static members
|
||||
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> kotlin.Unit!)!): kotlin.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
|
||||
public open class C : test.FakeStaticOverrides.B {
|
||||
public constructor C()
|
||||
|
||||
// Static members
|
||||
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> kotlin.Unit!)!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ public final class StaticOverrides {
|
||||
|
||||
// Static members
|
||||
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> kotlin.Unit!)!): kotlin.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,5 @@ public open class Basic {
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable!): kotlin.Unit
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ p0: (() -> kotlin.Unit)!): kotlin.Unit
|
||||
public open fun bar(/*0*/ p0: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -4,6 +4,5 @@ public open class SeveralSamParameters {
|
||||
public constructor SeveralSamParameters()
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun findMaxAndInvokeCallback(/*0*/ p0: ((kotlin.String!, kotlin.String!) -> kotlin.Int)!, /*1*/ p1: kotlin.String!, /*2*/ p2: kotlin.String!, /*3*/ p3: (() -> kotlin.Unit)!): kotlin.String!
|
||||
public open fun findMaxAndInvokeCallback(/*0*/ p0: java.util.Comparator<kotlin.String!>!, /*1*/ p1: kotlin.String!, /*2*/ p2: kotlin.String!, /*3*/ p3: java.lang.Runnable!): kotlin.String!
|
||||
}
|
||||
|
||||
-3
@@ -4,10 +4,7 @@ public open class TypeParameterOfMethod {
|
||||
public constructor TypeParameterOfMethod()
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun </*0*/ T : kotlin.Any!> max(/*0*/ p0: ((T!, T!) -> kotlin.Int)!, /*1*/ p1: T!, /*2*/ p2: T!): T!
|
||||
public open fun </*0*/ T : kotlin.Any!> max(/*0*/ p0: java.util.Comparator<T!>!, /*1*/ p1: T!, /*2*/ p2: T!): T!
|
||||
public final /*synthesized*/ fun </*0*/ T : kotlin.CharSequence!> max2(/*0*/ p0: ((T!, T!) -> kotlin.Int)!, /*1*/ p1: T!, /*2*/ p2: T!): T!
|
||||
public open fun </*0*/ T : kotlin.CharSequence!> max2(/*0*/ p0: java.util.Comparator<T!>!, /*1*/ p1: T!, /*2*/ p2: T!): T!
|
||||
public final /*synthesized*/ fun </*0*/ A : kotlin.CharSequence!, /*1*/ B : kotlin.collections.(Mutable)List<A!>!> method(/*0*/ p0: ((A!, A!) -> kotlin.Int)!, /*1*/ p1: B!): kotlin.Unit
|
||||
public open fun </*0*/ A : kotlin.CharSequence!, /*1*/ B : kotlin.collections.(Mutable)List<A!>!> method(/*0*/ p0: java.util.Comparator<A!>!, /*1*/ p1: B!): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -12489,12 +12489,30 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedStaticSam.kt")
|
||||
public void testInheritedStaticSam() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/sam/inheritedStaticSam.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("samOnTypeParameter.kt")
|
||||
public void testSamOnTypeParameter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/sam/samOnTypeParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("staticSamFromImportWithStar.kt")
|
||||
public void testStaticSamFromImportWithStar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/sam/staticSamFromImportWithStar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("staticSamWithExplicitImport.kt")
|
||||
public void testStaticSamWithExplicitImport() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/sam/staticSamWithExplicitImport.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeInferenceOnSamAdapters.kt")
|
||||
public void testTypeInferenceOnSamAdapters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/sam/typeInferenceOnSamAdapters.kt");
|
||||
|
||||
@@ -1613,6 +1613,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("samAgainstFunctionalType.kt")
|
||||
public void testSamAgainstFunctionalType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/resolve/samAgainstFunctionalType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("samConstructorVsFun.kt")
|
||||
public void testSamConstructorVsFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/resolve/samConstructorVsFun.kt");
|
||||
|
||||
@@ -1357,6 +1357,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FakeStaticOverrides.java")
|
||||
public void testFakeStaticOverrides() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/FakeStaticOverrides.java");
|
||||
doTestCompiledJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FilenameFilter.java")
|
||||
public void testFilenameFilter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/FilenameFilter.java");
|
||||
|
||||
+6
@@ -1355,6 +1355,12 @@ public class LoadJavaWithFastClassReadingTestGenerated extends AbstractLoadJavaW
|
||||
doTestCompiledJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FakeStaticOverrides.java")
|
||||
public void testFakeStaticOverrides() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/FakeStaticOverrides.java");
|
||||
doTestCompiledJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FilenameFilter.java")
|
||||
public void testFilenameFilter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/FilenameFilter.java");
|
||||
|
||||
+2
-5
@@ -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
-1
@@ -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) }
|
||||
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user