Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
package io.github.kyay10.highkt

import io.github.kyay10.highkt.fir.AddTypeAssertTransformer
import io.github.kyay10.highkt.fir.AddTypeToTypeAssertTransformer
import io.github.kyay10.highkt.fir.HighKTCheckers
import io.github.kyay10.highkt.fir.KindExpectedTypeCanonicalizer
import io.github.kyay10.highkt.fir.KindReturnTypeRefiner
import org.jetbrains.kotlin.fir.extensions.FirExtensionApiInternals
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar

class HighKTRegistrar : FirExtensionRegistrar() {
@OptIn(FirExtensionApiInternals::class)
override fun ExtensionRegistrarContext.configurePlugin() {
+::AddTypeAssertTransformer
+::AddTypeToTypeAssertTransformer
+::KindReturnTypeRefiner
+::KindExpectedTypeCanonicalizer
+::HighKTCheckers
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.github.kyay10.highkt.fir

import org.jetbrains.kotlin.fir.types.ConeAttribute
import org.jetbrains.kotlin.fir.types.ConeAttributeWithConeType
import org.jetbrains.kotlin.fir.types.ConeAttributes
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.renderForDebugging
import org.jetbrains.kotlin.fir.types.renderReadable

class ExpandedTypeAttribute(override val coneType: ConeKotlinType) : ConeAttributeWithConeType<ExpandedTypeAttribute>() {
override fun copyWith(newType: ConeKotlinType) =
ExpandedTypeAttribute(coneType = newType)
override fun add(other: ExpandedTypeAttribute?) = other ?: this
override fun intersect(other: ExpandedTypeAttribute?) = other ?: this
override fun isSubtypeOf(other: ExpandedTypeAttribute?) = true
override fun renderForReadability() = "${coneType.renderReadable()} ~> "
override fun toString(): String = "{${coneType.renderForDebugging()} ~>}"
override fun union(other: ExpandedTypeAttribute?) = other ?: this
override val keepInInferredDeclarationType get() = true
override val key get() = ExpandedTypeAttribute::class
}

val ConeAttributes.expandedType by ConeAttributes.attributeAccessor<ExpandedTypeAttribute>()

data object LeaveUnevaluatedAttribute : ConeAttribute<LeaveUnevaluatedAttribute>() {
override fun add(other: LeaveUnevaluatedAttribute?) = other ?: this
override fun intersect(other: LeaveUnevaluatedAttribute?) = other ?: this

override fun isSubtypeOf(other: LeaveUnevaluatedAttribute?) = true

override fun union(other: LeaveUnevaluatedAttribute?) = other ?: this
override val key = LeaveUnevaluatedAttribute::class
override val keepInInferredDeclarationType: Boolean get() = false
override fun renderForReadability() = "[LeaveUnevaluated]"
override fun toString(): String = "{LeaveUnevaluated}"
}

val ConeAttributes.leaveUnevaluated by ConeAttributes.attributeAccessor<LeaveUnevaluatedAttribute>()
val ConeAttributes.shouldLeaveUnevaluated get() = this.leaveUnevaluated != null
Loading