@@ -52,7 +52,6 @@ import org.jetbrains.kotlin.fir.resolve.toClassSymbol
52
52
import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol
53
53
import org.jetbrains.kotlin.fir.scopes.FirKotlinScopeProvider
54
54
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
55
- import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
56
55
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagWithFixedSymbol
57
56
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol
58
57
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
@@ -66,14 +65,16 @@ import org.jetbrains.kotlin.fir.types.ConeTypeProjection
66
65
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
67
66
import org.jetbrains.kotlin.fir.types.builder.buildTypeProjectionWithVariance
68
67
import org.jetbrains.kotlin.fir.types.classId
69
- import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
68
+ import org.jetbrains.kotlin.fir.types.constructClassLikeType
69
+ import org.jetbrains.kotlin.fir.types.constructClassType
70
70
import org.jetbrains.kotlin.fir.types.impl.FirImplicitAnyTypeRef
71
71
import org.jetbrains.kotlin.fir.types.resolvedType
72
72
import org.jetbrains.kotlin.fir.visitors.FirTransformer
73
73
import org.jetbrains.kotlin.name.CallableId
74
74
import org.jetbrains.kotlin.name.ClassId
75
75
import org.jetbrains.kotlin.name.FqName
76
76
import org.jetbrains.kotlin.name.Name
77
+ import org.jetbrains.kotlin.name.StandardClassIds
77
78
import org.jetbrains.kotlin.text
78
79
import org.jetbrains.kotlin.types.Variance
79
80
import org.jetbrains.kotlinx.dataframe.plugin.DataFramePlugin
@@ -179,33 +180,29 @@ class FunctionCallTransformer(
179
180
return newType?.generatedClasses?.get(name)
180
181
}
181
182
182
- inner class DataSchemaLikeCallTransformer (val classId : ClassId ) : CallTransformer {
183
+ inner class DataSchemaLikeCallTransformer (val dataSchemaLikeClassId : ClassId ) : CallTransformer {
183
184
override fun interceptOrNull (callInfo : CallInfo , symbol : FirNamedFunctionSymbol , hash : String ): CallReturnType ? {
184
- if (symbol.resolvedReturnType.fullyExpandedClassId(session) != classId ) return null
185
+ if (symbol.resolvedReturnType.fullyExpandedClassId(session) != dataSchemaLikeClassId ) return null
185
186
// possibly null if explicit receiver type is typealias
186
187
val argument = (callInfo.explicitReceiver?.resolvedType)?.typeArguments?.getOrNull(0 )
187
188
val newDataFrameArgument = buildNewTypeArgument(argument, callInfo.name, hash, callInfo.callSite)
188
189
189
- val lookupTag = ConeClassLikeLookupTagImpl (classId)
190
190
val typeRef = buildResolvedTypeRef {
191
- coneType = ConeClassLikeTypeImpl (
192
- lookupTag,
193
- arrayOf(
194
- ConeClassLikeTypeImpl (
195
- ConeClassLikeLookupTagWithFixedSymbol (newDataFrameArgument.classId, newDataFrameArgument.symbol),
196
- emptyArray(),
197
- isMarkedNullable = false
198
- )
199
- ),
200
- isMarkedNullable = false
191
+ coneType = dataSchemaLikeClassId.constructClassLikeType(
192
+ typeArguments = arrayOf(
193
+ ConeClassLikeLookupTagWithFixedSymbol (
194
+ newDataFrameArgument.classId,
195
+ newDataFrameArgument.symbol
196
+ ).constructClassType()
197
+ )
201
198
)
202
199
}
203
200
return CallReturnType (typeRef)
204
201
}
205
202
206
203
@OptIn(SymbolInternals ::class )
207
204
override fun transformOrNull (call : FirFunctionCall , originalSymbol : FirNamedFunctionSymbol ): FirFunctionCall ? {
208
- val callResult = analyzeRefinedCallShape<PluginDataFrameSchema >(call, classId , InterpretationErrorReporter .DEFAULT )
205
+ val callResult = analyzeRefinedCallShape<PluginDataFrameSchema >(call, dataSchemaLikeClassId , InterpretationErrorReporter .DEFAULT )
209
206
val (tokens, dataFrameSchema) = callResult ? : return null
210
207
val token = tokens[0 ]
211
208
val firstSchema = token.toClassSymbol(session)?.resolvedSuperTypes?.get(0 )!! .toRegularClassSymbol(session)?.fir!!
@@ -233,23 +230,12 @@ class FunctionCallTransformer(
233
230
if (symbol.resolvedReturnType.fullyExpandedClassId(session) != Names .GROUP_BY_CLASS_ID ) return null
234
231
val keys = buildNewTypeArgument(null , Name .identifier(" Key" ), hash, callInfo.callSite)
235
232
val group = buildNewTypeArgument(null , Name .identifier(" Group" ), hash, callInfo.callSite)
236
- val lookupTag = ConeClassLikeLookupTagImpl (Names .GROUP_BY_CLASS_ID )
237
233
val typeRef = buildResolvedTypeRef {
238
- coneType = ConeClassLikeTypeImpl (
239
- lookupTag,
240
- arrayOf(
241
- ConeClassLikeTypeImpl (
242
- ConeClassLikeLookupTagWithFixedSymbol (keys.classId, keys.symbol),
243
- emptyArray<ConeTypeProjection >(),
244
- isMarkedNullable = false
245
- ),
246
- ConeClassLikeTypeImpl (
247
- ConeClassLikeLookupTagWithFixedSymbol (group.classId, group.symbol),
248
- emptyArray<ConeTypeProjection >(),
249
- isMarkedNullable = false
250
- )
251
- ),
252
- isMarkedNullable = false
234
+ coneType = Names .GROUP_BY_CLASS_ID .constructClassLikeType(
235
+ typeArguments = arrayOf(
236
+ ConeClassLikeLookupTagWithFixedSymbol (keys.classId, keys.symbol).constructClassType(),
237
+ ConeClassLikeLookupTagWithFixedSymbol (group.classId, group.symbol).constructClassType(),
238
+ )
253
239
)
254
240
}
255
241
return CallReturnType (typeRef)
@@ -325,11 +311,7 @@ class FunctionCallTransformer(
325
311
classKind = ClassKind .CLASS
326
312
scopeProvider = FirKotlinScopeProvider ()
327
313
superTypeRefs + = buildResolvedTypeRef {
328
- coneType = ConeClassLikeTypeImpl (
329
- ConeClassLikeLookupTagWithFixedSymbol (tokenId, token.symbol),
330
- emptyArray(),
331
- isMarkedNullable = false
332
- )
314
+ coneType = ConeClassLikeLookupTagWithFixedSymbol (tokenId, token.symbol).constructClassType()
333
315
}
334
316
335
317
this .name = dataFrameTypeId.shortClassName
@@ -449,16 +431,12 @@ class FunctionCallTransformer(
449
431
hasExplicitParameterList = false
450
432
typeRef = buildResolvedTypeRef {
451
433
coneType = if (receiverType != null ) {
452
- ConeClassLikeTypeImpl (
453
- ConeClassLikeLookupTagImpl (ClassId (FqName (" kotlin" ), Name .identifier(" Function1" ))),
454
- typeArguments = arrayOf(receiverType, returnType),
455
- isMarkedNullable = false
434
+ StandardClassIds .FunctionN (1 ).constructClassLikeType(
435
+ typeArguments = arrayOf(receiverType, returnType)
456
436
)
457
437
} else {
458
- ConeClassLikeTypeImpl (
459
- ConeClassLikeLookupTagImpl (ClassId (FqName (" kotlin" ), Name .identifier(" Function0" ))),
460
- typeArguments = arrayOf(returnType),
461
- isMarkedNullable = false
438
+ StandardClassIds .FunctionN (0 ).constructClassLikeType(
439
+ typeArguments = arrayOf(returnType)
462
440
)
463
441
}
464
442
}
@@ -555,30 +533,22 @@ class FunctionCallTransformer(
555
533
is SimpleColumnGroup -> {
556
534
val nestedSchema = PluginDataFrameSchema (it.columns()).materialize(it)
557
535
val columnsContainerReturnType =
558
- ConeClassLikeTypeImpl (
559
- ConeClassLikeLookupTagImpl (Names .COLUM_GROUP_CLASS_ID ),
560
- typeArguments = arrayOf(nestedSchema.schema.defaultType()),
561
- isMarkedNullable = false
536
+ Names .COLUM_GROUP_CLASS_ID .constructClassLikeType(
537
+ typeArguments = arrayOf(nestedSchema.schema.defaultType())
562
538
)
563
539
564
- val dataRowReturnType =
565
- ConeClassLikeTypeImpl (
566
- ConeClassLikeLookupTagImpl (Names .DATA_ROW_CLASS_ID ),
567
- typeArguments = arrayOf(nestedSchema.schema.defaultType()),
568
- isMarkedNullable = false
569
- )
540
+ val dataRowReturnType = Names .DATA_ROW_CLASS_ID .constructClassLikeType(
541
+ typeArguments = arrayOf(nestedSchema.schema.defaultType())
542
+ )
570
543
571
544
SchemaProperty (schema.defaultType(), PropertyName .of(it.name), dataRowReturnType, columnsContainerReturnType)
572
545
}
573
546
574
547
is SimpleFrameColumn -> {
575
548
val nestedClassMarker = PluginDataFrameSchema (it.columns()).materialize(it)
576
- val frameColumnReturnType =
577
- ConeClassLikeTypeImpl (
578
- ConeClassLikeLookupTagImpl (Names .DF_CLASS_ID ),
579
- typeArguments = arrayOf(nestedClassMarker.schema.defaultType()),
580
- isMarkedNullable = false
581
- )
549
+ val frameColumnReturnType = Names .DF_CLASS_ID .constructClassLikeType(
550
+ typeArguments = arrayOf(nestedClassMarker.schema.defaultType())
551
+ )
582
552
583
553
SchemaProperty (
584
554
marker = schema.defaultType(),
0 commit comments