SAM constructors for type aliases.
This commit is contained in:
+34
-8
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.*;
|
||||
@@ -134,28 +135,41 @@ public class SingleAbstractMethodUtils {
|
||||
) {
|
||||
assert getSingleAbstractMethodOrNull(samInterface) != null : samInterface;
|
||||
|
||||
SamConstructorDescriptor result = new SamConstructorDescriptor(owner, samInterface);
|
||||
SamConstructorDescriptorImpl result = new SamConstructorDescriptorImpl(owner, samInterface);
|
||||
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samInterface.getTypeConstructor().getParameters(), result);
|
||||
List<TypeParameterDescriptor> samTypeParameters = samInterface.getTypeConstructor().getParameters();
|
||||
SimpleType unsubstitutedSamType = samInterface.getDefaultType();
|
||||
initializeSamConstructorDescriptor(samInterface, result, samTypeParameters, unsubstitutedSamType);
|
||||
|
||||
KotlinType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + samInterface.getDefaultType();
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void initializeSamConstructorDescriptor(
|
||||
@NotNull JavaClassDescriptor samInterface,
|
||||
@NotNull SimpleFunctionDescriptorImpl samConstructor,
|
||||
@NotNull List<TypeParameterDescriptor> samTypeParameters,
|
||||
@NotNull KotlinType unsubstitutedSamType
|
||||
) {
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samTypeParameters, samConstructor);
|
||||
|
||||
KotlinType parameterTypeUnsubstituted = getFunctionTypeForSamType(unsubstitutedSamType);
|
||||
assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + unsubstitutedSamType;
|
||||
KotlinType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||
result, null, 0, Annotations.Companion.getEMPTY(), Name.identifier("function"), parameterType,
|
||||
samConstructor, null, 0, Annotations.Companion.getEMPTY(), Name.identifier("function"), parameterType,
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null, SourceElement.NO_SOURCE);
|
||||
|
||||
KotlinType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() +
|
||||
KotlinType returnType = typeParameters.substitutor.substitute(unsubstitutedSamType, Variance.OUT_VARIANCE);
|
||||
assert returnType != null : "couldn't substitute type: " + unsubstitutedSamType +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
|
||||
result.initialize(
|
||||
samConstructor.initialize(
|
||||
null,
|
||||
null,
|
||||
typeParameters.descriptors,
|
||||
@@ -164,6 +178,18 @@ public class SingleAbstractMethodUtils {
|
||||
Modality.FINAL,
|
||||
samInterface.getVisibility()
|
||||
);
|
||||
}
|
||||
|
||||
public static SamConstructorDescriptor createTypeAliasSamConstructorFunction(
|
||||
@NotNull TypeAliasDescriptor typeAliasDescriptor,
|
||||
@NotNull SamConstructorDescriptor underlyingSamConstructor
|
||||
) {
|
||||
SamTypeAliasConstructorDescriptorImpl result = new SamTypeAliasConstructorDescriptorImpl(typeAliasDescriptor, underlyingSamConstructor);
|
||||
|
||||
JavaClassDescriptor samInterface = underlyingSamConstructor.getBaseDescriptorForSynthetic();
|
||||
List<TypeParameterDescriptor> samTypeParameters = typeAliasDescriptor.getTypeConstructor().getParameters();
|
||||
SimpleType unsubstitutedSamType = typeAliasDescriptor.getExpandedType();
|
||||
initializeSamConstructorDescriptor(samInterface, result, samTypeParameters, unsubstitutedSamType);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+2
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmOverloadFilter
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmTypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.resolve.jvm.RuntimeAssertionsTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.jvm.checkers.*
|
||||
import org.jetbrains.kotlin.synthetic.JavaSyntheticConstructorsProvider
|
||||
import org.jetbrains.kotlin.synthetic.JavaSyntheticScopes
|
||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
|
||||
@@ -81,6 +82,7 @@ object JvmPlatformConfigurator : PlatformConfigurator(
|
||||
|
||||
container.useImpl<ReflectionAPICallChecker>()
|
||||
container.useImpl<JavaSyntheticScopes>()
|
||||
container.useInstance(JavaSyntheticConstructorsProvider)
|
||||
container.useInstance(JvmTypeSpecificityComparator)
|
||||
}
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.synthetic
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticConstructorsProvider
|
||||
import java.lang.AssertionError
|
||||
|
||||
object JavaSyntheticConstructorsProvider : SyntheticConstructorsProvider {
|
||||
override fun getSyntheticConstructors(classifier: ClassifierDescriptor, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
if (classifier is TypeAliasDescriptor) {
|
||||
return getSyntheticTypeAliasConstructors(classifier, location)
|
||||
}
|
||||
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
private fun getSyntheticTypeAliasConstructors(typeAliasDescriptor: TypeAliasDescriptor, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
val classDescriptor = typeAliasDescriptor.classDescriptor
|
||||
if (classDescriptor !is LazyJavaClassDescriptor || classDescriptor.functionTypeForSamInterface == null) return emptyList()
|
||||
|
||||
val containingDeclaration = classDescriptor.containingDeclaration
|
||||
|
||||
val outerScope = when (containingDeclaration) {
|
||||
is ClassDescriptor ->
|
||||
containingDeclaration.staticScope
|
||||
is PackageFragmentDescriptor ->
|
||||
containingDeclaration.getMemberScope()
|
||||
else ->
|
||||
throw AssertionError("Unexpected containing declaration for $classDescriptor: $containingDeclaration")
|
||||
}
|
||||
|
||||
return outerScope.getContributedFunctions(classDescriptor.name, location)
|
||||
.filterIsInstance<SamConstructorDescriptorImpl>()
|
||||
.filter { it.baseDescriptorForSynthetic == classDescriptor }
|
||||
.map { SingleAbstractMethodUtils.createTypeAliasSamConstructorFunction(typeAliasDescriptor, it) }
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.*
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticConstructorsProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
@@ -47,6 +48,7 @@ abstract class TargetPlatform(
|
||||
override fun configure(container: StorageComponentContainer) {
|
||||
super.configure(container)
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
container.useInstance(SyntheticConstructorsProvider.Empty)
|
||||
container.useInstance(TypeSpecificityComparator.NONE)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
@@ -44,17 +43,16 @@ import org.jetbrains.kotlin.resolve.calls.tasks.*
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticConstructorsProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
import org.jetbrains.kotlin.types.typeUtil.containsError
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import java.lang.IllegalStateException
|
||||
import java.util.*
|
||||
|
||||
class NewResolutionOldInference(
|
||||
@@ -62,7 +60,8 @@ class NewResolutionOldInference(
|
||||
private val towerResolver: TowerResolver,
|
||||
private val resolutionResultsHandler: ResolutionResultsHandler,
|
||||
private val dynamicCallableDescriptors: DynamicCallableDescriptors,
|
||||
private val syntheticScopes: SyntheticScopes
|
||||
private val syntheticScopes: SyntheticScopes,
|
||||
private val syntheticConstructorsProvider: SyntheticConstructorsProvider
|
||||
) {
|
||||
|
||||
sealed class ResolutionKind<D : CallableDescriptor> {
|
||||
@@ -151,7 +150,7 @@ class NewResolutionOldInference(
|
||||
}
|
||||
|
||||
val dynamicScope = dynamicCallableDescriptors.createDynamicDescriptorScope(context.call, context.scope.ownerDescriptor)
|
||||
val scopeTower = ImplicitScopeTowerImpl(context, dynamicScope, syntheticScopes, context.call.createLookupLocation())
|
||||
val scopeTower = ImplicitScopeTowerImpl(context, dynamicScope, syntheticScopes, syntheticConstructorsProvider, context.call.createLookupLocation())
|
||||
|
||||
val processor = kind.createTowerProcessor(this, name, tracing, scopeTower, detailedReceiver, context)
|
||||
|
||||
@@ -282,6 +281,7 @@ class NewResolutionOldInference(
|
||||
val resolutionContext: ResolutionContext<*>,
|
||||
override val dynamicScope: MemberScope,
|
||||
override val syntheticScopes: SyntheticScopes,
|
||||
override val syntheticConstructorsProvider: SyntheticConstructorsProvider,
|
||||
override val location: LookupLocation
|
||||
): ImplicitScopeTower {
|
||||
private val cache = HashMap<ReceiverValue, ReceiverValueWithSmartCastInfo>()
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticConstructorsProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -34,6 +35,8 @@ interface ImplicitScopeTower {
|
||||
|
||||
val syntheticScopes: SyntheticScopes
|
||||
|
||||
val syntheticConstructorsProvider: SyntheticConstructorsProvider
|
||||
|
||||
val location: LookupLocation
|
||||
|
||||
val isDebuggerContext: Boolean
|
||||
|
||||
@@ -161,7 +161,7 @@ internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qual
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?) = qualifier.staticScope
|
||||
.getContributedFunctionsAndConstructors(name, location).map {
|
||||
.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticConstructorsProvider).map {
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
||||
private val resolutionScope: ResolutionScope
|
||||
) : AbstractScopeTowerLevel(scopeTower) {
|
||||
|
||||
internal constructor(scopeTower: ImplicitScopeTower, lexicalScope: LexicalScope): this(scopeTower, lexicalScope as ResolutionScope)
|
||||
internal constructor(scopeTower: ImplicitScopeTower, lexicalScope: LexicalScope) : this(scopeTower, lexicalScope as ResolutionScope)
|
||||
|
||||
override fun getVariables(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?): Collection<CandidateWithBoundDispatchReceiver<VariableDescriptor>>
|
||||
= resolutionScope.getContributedVariables(name, location).map {
|
||||
@@ -185,7 +185,7 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?): Collection<CandidateWithBoundDispatchReceiver<FunctionDescriptor>>
|
||||
= resolutionScope.getContributedFunctionsAndConstructors(name, location).map {
|
||||
= resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticConstructorsProvider).map {
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
}
|
||||
}
|
||||
@@ -260,11 +260,17 @@ private fun KotlinType?.getInnerConstructors(name: Name, location: LookupLocatio
|
||||
return classifierDescriptor?.constructors?.filter { it.dispatchReceiverParameter != null } ?: emptyList()
|
||||
}
|
||||
|
||||
private fun ResolutionScope.getContributedFunctionsAndConstructors(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
private fun ResolutionScope.getContributedFunctionsAndConstructors(
|
||||
name: Name,
|
||||
location: LookupLocation,
|
||||
syntheticConstructorsProvider: SyntheticConstructorsProvider
|
||||
): Collection<FunctionDescriptor> {
|
||||
val classifier = getContributedClassifier(name, location)
|
||||
return getContributedFunctions(name, location) +
|
||||
(getClassWithConstructors(classifier)?.constructors?.filter { it.dispatchReceiverParameter == null } ?: emptyList()) +
|
||||
(classifier?.getTypeAliasConstructors()?.filter { it.dispatchReceiverParameter == null } ?: emptyList())
|
||||
(classifier?.getTypeAliasConstructors()?.filter { it.dispatchReceiverParameter == null } ?: emptyList()) +
|
||||
(classifier?.let { syntheticConstructorsProvider.getSyntheticConstructors(it, location) }
|
||||
?.filter { it.dispatchReceiverParameter == null } ?: emptyList())
|
||||
}
|
||||
|
||||
private fun ResolutionScope.getContributedObjectVariables(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// FILE: test.kt
|
||||
typealias RunnableT = java.lang.Runnable
|
||||
typealias ComparatorT<T> = java.util.Comparator<T>
|
||||
typealias ComparatorStrT = ComparatorT<String>
|
||||
|
||||
val test1 = RunnableT { }
|
||||
val test2 = ComparatorT<String> { s1, s2 -> s1.compareTo(s2) }
|
||||
val test3 = ComparatorStrT { s1, s2 -> s1.compareTo(s2) }
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
package
|
||||
|
||||
public val test1: java.lang.Runnable
|
||||
public val test2: java.util.Comparator<kotlin.String>
|
||||
public val test3: ComparatorT<kotlin.String> /* = java.util.Comparator<kotlin.String> */
|
||||
public typealias ComparatorStrT = ComparatorT<kotlin.String>
|
||||
public typealias ComparatorT</*0*/ T> = java.util.Comparator<T>
|
||||
public typealias RunnableT = java.lang.Runnable
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: JHost.java
|
||||
public class JHost {
|
||||
public static interface Runnable {
|
||||
void run();
|
||||
}
|
||||
|
||||
public static interface Consumer<T> {
|
||||
void consume(T x);
|
||||
}
|
||||
|
||||
public static interface Consumer2<T1, T2> {
|
||||
void run(T1 x1, T2 x2);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
typealias R = JHost.Runnable
|
||||
typealias C<T> = JHost.Consumer<T>
|
||||
typealias CStr = JHost.Consumer<String>
|
||||
typealias CStrList = JHost.Consumer<List<String>>
|
||||
typealias C2<T> = JHost.Consumer2<T, T>
|
||||
|
||||
val test1 = R { }
|
||||
val test2 = C<String> { s -> println(s.length) }
|
||||
val test3 = CStr { s -> println(s.length) }
|
||||
val test4 = CStrList { ss -> for (s in ss) { println(s.length) } }
|
||||
val test5 = C2<Int> { a, b -> val x: Int = a + b; println(x)}
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
package
|
||||
|
||||
public val test1: JHost.Runnable
|
||||
public val test2: JHost.Consumer<kotlin.String>
|
||||
public val test3: JHost.Consumer<kotlin.String>
|
||||
public val test4: JHost.Consumer<kotlin.collections.List<kotlin.String>>
|
||||
public val test5: JHost.Consumer2<kotlin.Int, kotlin.Int>
|
||||
|
||||
public open class JHost {
|
||||
public constructor JHost()
|
||||
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 interface Consumer</*0*/ T : kotlin.Any!> {
|
||||
public abstract fun consume(/*0*/ x: T!): kotlin.Unit
|
||||
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 interface Consumer2</*0*/ T1 : kotlin.Any!, /*1*/ T2 : kotlin.Any!> {
|
||||
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 abstract fun run(/*0*/ x1: T1!, /*1*/ x2: T2!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Runnable {
|
||||
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 abstract fun run(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun </*0*/ T : kotlin.Any!> Consumer(/*0*/ function: (T!) -> kotlin.Unit): JHost.Consumer<T>
|
||||
public final /*synthesized*/ fun </*0*/ T1 : kotlin.Any!, /*1*/ T2 : kotlin.Any!> Consumer2(/*0*/ function: (T1!, T2!) -> kotlin.Unit): JHost.Consumer2<T1, T2>
|
||||
public final /*synthesized*/ fun Runnable(/*0*/ function: () -> kotlin.Unit): JHost.Runnable
|
||||
}
|
||||
public typealias C</*0*/ T> = JHost.Consumer<T>
|
||||
public typealias C2</*0*/ T> = JHost.Consumer2<T, T>
|
||||
public typealias CStr = JHost.Consumer<kotlin.String>
|
||||
public typealias CStrList = JHost.Consumer<kotlin.collections.List<kotlin.String>>
|
||||
public typealias R = JHost.Runnable
|
||||
@@ -1250,6 +1250,27 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/typealias")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Typealias extends AbstractDiagnosticsTestWithStdLib {
|
||||
public void testAllFilesPresentInTypealias() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasSamAdapterConstructors.kt")
|
||||
public void testTypeAliasSamAdapterConstructors() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/typealias/typeAliasSamAdapterConstructors.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasSamAdapterConstructors2.kt")
|
||||
public void testTypeAliasSamAdapterConstructors2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/typealias/typeAliasSamAdapterConstructors2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/varargs")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+5
-2
@@ -18,11 +18,14 @@ package org.jetbrains.kotlin.load.java.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
||||
|
||||
class SamConstructorDescriptor(
|
||||
interface SamConstructorDescriptor : SimpleFunctionDescriptor, SyntheticMemberDescriptor<JavaClassDescriptor>
|
||||
|
||||
class SamConstructorDescriptorImpl(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
private val samInterface: JavaClassDescriptor
|
||||
) : SimpleFunctionDescriptorImpl(
|
||||
@@ -32,7 +35,7 @@ class SamConstructorDescriptor(
|
||||
samInterface.name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
samInterface.source
|
||||
), SyntheticMemberDescriptor<JavaClassDescriptor> {
|
||||
), SamConstructorDescriptor {
|
||||
override val baseDescriptorForSynthetic: JavaClassDescriptor
|
||||
get() = samInterface
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.java.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
|
||||
interface SamTypeAliasConstructorDescriptor : SamConstructorDescriptor {
|
||||
val typeAliasDescriptor: TypeAliasDescriptor
|
||||
}
|
||||
|
||||
class SamTypeAliasConstructorDescriptorImpl(
|
||||
override val typeAliasDescriptor: TypeAliasDescriptor,
|
||||
private val samInterfaceConstructorDescriptor: SamConstructorDescriptor
|
||||
) : SimpleFunctionDescriptorImpl(
|
||||
typeAliasDescriptor.containingDeclaration,
|
||||
null,
|
||||
samInterfaceConstructorDescriptor.baseDescriptorForSynthetic.annotations,
|
||||
samInterfaceConstructorDescriptor.baseDescriptorForSynthetic.name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
typeAliasDescriptor.source
|
||||
), SamTypeAliasConstructorDescriptor {
|
||||
override val baseDescriptorForSynthetic: JavaClassDescriptor
|
||||
get() = samInterfaceConstructorDescriptor.baseDescriptorForSynthetic
|
||||
}
|
||||
@@ -20,8 +20,12 @@ import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
|
||||
interface TypeAliasDescriptor : ClassifierDescriptorWithTypeParameters, MemberDescriptor {
|
||||
/// Right-hand side of the type alias definition.
|
||||
/// May contain type aliases.
|
||||
val underlyingType: SimpleType
|
||||
|
||||
/// Fully expanded type with non-substituted type parameters.
|
||||
/// May not contain type aliases.
|
||||
val expandedType: SimpleType
|
||||
|
||||
val classDescriptor: ClassDescriptor?
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
|
||||
interface SyntheticConstructorsProvider {
|
||||
fun getSyntheticConstructors(classifier: ClassifierDescriptor, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
|
||||
object Empty : SyntheticConstructorsProvider {
|
||||
override fun getSyntheticConstructors(classifier: ClassifierDescriptor, location: LookupLocation): Collection<FunctionDescriptor> =
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.js.resolve.diagnostics.NativeInnerClassChecker
|
||||
import org.jetbrains.kotlin.resolve.IdentifierChecker
|
||||
import org.jetbrains.kotlin.resolve.OverloadFilter
|
||||
import org.jetbrains.kotlin.resolve.PlatformConfigurator
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticConstructorsProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.types.DynamicTypesAllowed
|
||||
|
||||
@@ -43,6 +44,7 @@ object JsPlatformConfigurator : PlatformConfigurator(
|
||||
|
||||
container.useImpl<JsCallChecker>()
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
container.useInstance(SyntheticConstructorsProvider.Empty)
|
||||
container.useInstance(JsTypeSpecificityComparator)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user