Code cleanup: data deprecations and some effective visibility stuff
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ interface Conditional {
|
||||
})
|
||||
}
|
||||
|
||||
data class JsVersion(): PlatformVersion {
|
||||
data class JsVersion(val version: Int = 5): PlatformVersion {
|
||||
companion object : Parser("JsVersion", parse = { JsVersion() })
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -18,22 +18,22 @@ package org.jetbrains.kotlin.preprocessor
|
||||
|
||||
interface Evaluator : (List<Conditional>) -> Boolean
|
||||
|
||||
abstract class PlatformEvaluator : Evaluator {
|
||||
final override fun invoke(conditions: List<Conditional>): Boolean = evaluate(conditions.filterIsInstance())
|
||||
interface PlatformEvaluator : Evaluator {
|
||||
override fun invoke(conditions: List<Conditional>): Boolean = evaluate(conditions.filterIsInstance())
|
||||
|
||||
open fun evaluate(conditions: List<Conditional.PlatformVersion>): Boolean
|
||||
= conditions.isEmpty() || conditions.any { match(it) }
|
||||
|
||||
abstract fun match(platformCondition: Conditional.PlatformVersion): Boolean
|
||||
fun match(platformCondition: Conditional.PlatformVersion): Boolean
|
||||
}
|
||||
|
||||
data class JvmPlatformEvaluator(val version: Int): PlatformEvaluator() {
|
||||
data class JvmPlatformEvaluator(val version: Int): PlatformEvaluator {
|
||||
override fun match(platformCondition: Conditional.PlatformVersion)
|
||||
= platformCondition is Conditional.JvmVersion && version in platformCondition.versionRange
|
||||
override fun toString() = "platform: JVM$version"
|
||||
}
|
||||
|
||||
data class JsPlatformEvaluator(val ecmaScriptVersion: Int = 5): PlatformEvaluator() {
|
||||
data class JsPlatformEvaluator(val ecmaScriptVersion: Int = 5): PlatformEvaluator {
|
||||
override fun match(platformCondition: Conditional.PlatformVersion)
|
||||
= platformCondition is Conditional.JsVersion
|
||||
override fun toString() = "platform: JS"
|
||||
|
||||
+10
-2
@@ -26,8 +26,16 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
public sealed class AccessTarget {
|
||||
public data class Declaration(val descriptor: VariableDescriptor): AccessTarget()
|
||||
public data class Call(val resolvedCall: ResolvedCall<*>): AccessTarget()
|
||||
public class Declaration(val descriptor: VariableDescriptor): AccessTarget() {
|
||||
override fun equals(other: Any?) = other is Declaration && descriptor == other.descriptor
|
||||
|
||||
override fun hashCode() = descriptor.hashCode()
|
||||
}
|
||||
public class Call(val resolvedCall: ResolvedCall<*>): AccessTarget() {
|
||||
override fun equals(other: Any?) = other is Call && resolvedCall == other.resolvedCall
|
||||
|
||||
override fun hashCode() = resolvedCall.hashCode()
|
||||
}
|
||||
public object BlackBox: AccessTarget()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user