Fix type alias problems after rebase.
This commit is contained in:
@@ -725,7 +725,7 @@ public class DescriptorResolver {
|
|||||||
ErrorUtils.createErrorType(name.asString()));
|
ErrorUtils.createErrorType(name.asString()));
|
||||||
}
|
}
|
||||||
else if (!languageFeatureSettings.supportsFeature(LanguageFeature.TypeAliases)) {
|
else if (!languageFeatureSettings.supportsFeature(LanguageFeature.TypeAliases)) {
|
||||||
typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace, true);
|
typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace);
|
||||||
PsiElement typeAliasKeyword = typeAlias.getTypeAliasKeyword();
|
PsiElement typeAliasKeyword = typeAlias.getTypeAliasKeyword();
|
||||||
trace.report(UNSUPPORTED_TYPEALIAS.on(typeAliasKeyword != null ? typeAliasKeyword : typeAlias));
|
trace.report(UNSUPPORTED_TYPEALIAS.on(typeAliasKeyword != null ? typeAliasKeyword : typeAlias));
|
||||||
typeAliasDescriptor.initialize(
|
typeAliasDescriptor.initialize(
|
||||||
@@ -739,14 +739,13 @@ public class DescriptorResolver {
|
|||||||
storageManager.createLazyValue(new Function0<SimpleType>() {
|
storageManager.createLazyValue(new Function0<SimpleType>() {
|
||||||
@Override
|
@Override
|
||||||
public SimpleType invoke() {
|
public SimpleType invoke() {
|
||||||
return typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace, true);
|
return typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
storageManager.createLazyValue(new Function0<SimpleType>() {
|
storageManager.createLazyValue(new Function0<SimpleType>() {
|
||||||
@Override
|
@Override
|
||||||
public SimpleType invoke() {
|
public SimpleType invoke() {
|
||||||
// TODO do not reparse
|
return typeResolver.resolveExpandedTypeForTypeAlias(typeAliasDescriptor);
|
||||||
return typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace, false);
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,23 +71,20 @@ class TypeResolver(
|
|||||||
return resolveType(TypeResolutionContext(scope, trace, checkBounds, false, typeReference.suppressDiagnosticsInDebugMode(), false), typeReference)
|
return resolveType(TypeResolutionContext(scope, trace, checkBounds, false, typeReference.suppressDiagnosticsInDebugMode(), false), typeReference)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resolveAbbreviatedType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, abbreviated: Boolean): SimpleType {
|
fun resolveAbbreviatedType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace): SimpleType {
|
||||||
return resolveSimpleType(
|
val resolvedType = resolveType(TypeResolutionContext(scope, trace, true, false, typeReference.suppressDiagnosticsInDebugMode(), true),
|
||||||
TypeResolutionContext(scope, trace, true, false, typeReference.suppressDiagnosticsInDebugMode(), abbreviated),
|
typeReference).unwrap()
|
||||||
typeReference
|
return when (resolvedType) {
|
||||||
)
|
is DynamicType -> {
|
||||||
}
|
trace.report(Errors.TYPEALIAS_SHOULD_EXPAND_TO_CLASS.on(typeReference, resolvedType))
|
||||||
|
ErrorUtils.createErrorType("dynamic type in wrong context")
|
||||||
private fun resolveSimpleType(c: TypeResolutionContext, typeReference: KtTypeReference): SimpleType {
|
}
|
||||||
val unwrappedType = resolveType(c, typeReference).unwrap()
|
is SimpleType -> resolvedType
|
||||||
return when (unwrappedType) {
|
else -> error("Unexpected type: $resolvedType")
|
||||||
is DynamicType -> ErrorUtils.createErrorType("dynamic type in wrong context")
|
|
||||||
is SimpleType -> unwrappedType
|
|
||||||
else -> error("Unexpected type: $unwrappedType")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resolveExpandedTypeForTypeAlias(typeAliasDescriptor: TypeAliasDescriptor): KotlinType {
|
fun resolveExpandedTypeForTypeAlias(typeAliasDescriptor: TypeAliasDescriptor): SimpleType {
|
||||||
val typeAliasExpansion = TypeAliasExpansion.createWithFormalArguments(typeAliasDescriptor)
|
val typeAliasExpansion = TypeAliasExpansion.createWithFormalArguments(typeAliasDescriptor)
|
||||||
val expandedType = TypeAliasExpander.NON_REPORTING.expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY)
|
val expandedType = TypeAliasExpander.NON_REPORTING.expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY)
|
||||||
return expandedType
|
return expandedType
|
||||||
|
|||||||
+8
-7
@@ -44,8 +44,8 @@ class DescriptorSerializer private constructor(
|
|||||||
}.toByteArray()
|
}.toByteArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createChildSerializer(callable: CallableDescriptor): DescriptorSerializer =
|
private fun createChildSerializer(descriptor: DeclarationDescriptor): DescriptorSerializer =
|
||||||
DescriptorSerializer(callable, Interner(typeParameters), extension, typeTable, serializeTypeTableToFunction = false)
|
DescriptorSerializer(descriptor, Interner(typeParameters), extension, typeTable, serializeTypeTableToFunction = false)
|
||||||
|
|
||||||
val stringTable: StringTable
|
val stringTable: StringTable
|
||||||
get() = extension.stringTable
|
get() = extension.stringTable
|
||||||
@@ -277,6 +277,7 @@ class DescriptorSerializer private constructor(
|
|||||||
|
|
||||||
fun typeAliasProto(descriptor: TypeAliasDescriptor): ProtoBuf.TypeAlias.Builder {
|
fun typeAliasProto(descriptor: TypeAliasDescriptor): ProtoBuf.TypeAlias.Builder {
|
||||||
val builder = ProtoBuf.TypeAlias.newBuilder()
|
val builder = ProtoBuf.TypeAlias.newBuilder()
|
||||||
|
val local = createChildSerializer(descriptor)
|
||||||
|
|
||||||
val flags = Flags.getTypeAliasFlags(hasAnnotations(descriptor), descriptor.visibility)
|
val flags = Flags.getTypeAliasFlags(hasAnnotations(descriptor), descriptor.visibility)
|
||||||
if (flags != builder.flags) {
|
if (flags != builder.flags) {
|
||||||
@@ -286,23 +287,23 @@ class DescriptorSerializer private constructor(
|
|||||||
builder.name = getSimpleNameIndex(descriptor.name)
|
builder.name = getSimpleNameIndex(descriptor.name)
|
||||||
|
|
||||||
for (typeParameterDescriptor in descriptor.declaredTypeParameters) {
|
for (typeParameterDescriptor in descriptor.declaredTypeParameters) {
|
||||||
builder.addTypeParameter(typeParameter(typeParameterDescriptor))
|
builder.addTypeParameter(local.typeParameter(typeParameterDescriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
val underlyingType = descriptor.underlyingType
|
val underlyingType = descriptor.underlyingType
|
||||||
if (useTypeTable()) {
|
if (useTypeTable()) {
|
||||||
builder.underlyingTypeId = typeId(underlyingType)
|
builder.underlyingTypeId = local.typeId(underlyingType)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
builder.setUnderlyingType(type(underlyingType))
|
builder.setUnderlyingType(local.type(underlyingType))
|
||||||
}
|
}
|
||||||
|
|
||||||
val expandedType = descriptor.expandedType
|
val expandedType = descriptor.expandedType
|
||||||
if (useTypeTable()) {
|
if (useTypeTable()) {
|
||||||
builder.expandedTypeId = typeId(expandedType)
|
builder.expandedTypeId = local.typeId(expandedType)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
builder.setExpandedType(type(expandedType))
|
builder.setExpandedType(local.type(expandedType))
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
|
|||||||
+6
-6
@@ -3,15 +3,15 @@ package
|
|||||||
public typealias ToFun1 = () -> kotlin.Unit
|
public typealias ToFun1 = () -> kotlin.Unit
|
||||||
public typealias ToFun2</*0*/ T> = (T) -> kotlin.Unit
|
public typealias ToFun2</*0*/ T> = (T) -> kotlin.Unit
|
||||||
public typealias ToTypeParam1</*0*/ T> = T
|
public typealias ToTypeParam1</*0*/ T> = T
|
||||||
public typealias ToTypeParam2</*0*/ T> = ToTypeParam1<T> [= T]
|
public typealias ToTypeParam2</*0*/ T> = ToTypeParam1<T>
|
||||||
public typealias ToTypeParam3</*0*/ T1, /*1*/ T2> = ToTypeParam2<T1> [= T1]
|
public typealias ToTypeParam3</*0*/ T1, /*1*/ T2> = ToTypeParam2<T1>
|
||||||
public typealias ToTypeParam4 = ToTypeParam1<kotlin.Any> [= kotlin.Any]
|
public typealias ToTypeParam4 = ToTypeParam1<kotlin.Any>
|
||||||
|
|
||||||
public final class Outer {
|
public final class Outer {
|
||||||
public typealias ToTypeParam1</*0*/ T> = T
|
public typealias ToTypeParam1</*0*/ T> = T
|
||||||
public typealias ToTypeParam2</*0*/ T> = Outer.ToTypeParam1<T> [= T]
|
public typealias ToTypeParam2</*0*/ T> = Outer.ToTypeParam1<T>
|
||||||
public typealias ToTypeParam3</*0*/ T1, /*1*/ T2> = Outer.ToTypeParam2<T1> [= T1]
|
public typealias ToTypeParam3</*0*/ T1, /*1*/ T2> = Outer.ToTypeParam2<T1>
|
||||||
public typealias ToTypeParam4 = Outer.ToTypeParam1<kotlin.Any> [= kotlin.Any]
|
public typealias ToTypeParam4 = Outer.ToTypeParam1<kotlin.Any>
|
||||||
public constructor Outer()
|
public constructor Outer()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
typealias Dyn = <!TYPEALIAS_SHOULD_EXPAND_TO_CLASS!>dynamic<!>
|
typealias Dyn = <!TYPEALIAS_SHOULD_EXPAND_TO_CLASS!>dynamic<!>
|
||||||
typealias Dyn2 = <!TYPEALIAS_SHOULD_EXPAND_TO_CLASS!>Dyn<!>
|
typealias Dyn2 = Dyn
|
||||||
typealias Dyn3 = <!TYPEALIAS_SHOULD_EXPAND_TO_CLASS!>Dyn2<!>
|
typealias Dyn3 = Dyn2
|
||||||
|
|
||||||
typealias Type<T> = <!TYPEALIAS_SHOULD_EXPAND_TO_CLASS!>T<!>
|
typealias Type<T> = <!TYPEALIAS_SHOULD_EXPAND_TO_CLASS!>T<!>
|
||||||
typealias Dyn4 = <!TYPEALIAS_SHOULD_EXPAND_TO_CLASS!>Type<Dyn><!>
|
typealias Dyn4 = Type<Dyn>
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public typealias Dyn = dynamic
|
public typealias Dyn = [ERROR : dynamic type in wrong context]
|
||||||
public typealias Dyn2 = Dyn
|
public typealias Dyn2 = Dyn
|
||||||
public typealias Dyn3 = Dyn2
|
public typealias Dyn3 = Dyn2
|
||||||
public typealias Dyn4 = Type<Dyn>
|
public typealias Dyn4 = Type<Dyn>
|
||||||
|
|||||||
Reference in New Issue
Block a user