Type Approximation: add separate flag to control approx. anonymous type
This extra flexibility is useful for IDE where we always want to approximate anonymous types but may not want to approximate other local types
This commit is contained in:
+2
-2
@@ -169,9 +169,9 @@ abstract class AbstractTypeApproximator(
|
||||
|
||||
private fun approximateLocalTypes(type: SimpleTypeMarker, conf: TypeApproximatorConfiguration, toSuper: Boolean): SimpleTypeMarker? {
|
||||
if (!toSuper) return null
|
||||
if (!conf.localTypes) return null
|
||||
if (!conf.localTypes && !conf.anonymous) return null
|
||||
val constructor = type.typeConstructor()
|
||||
val needApproximate = conf.localTypes && constructor.isLocalType()
|
||||
val needApproximate = (conf.localTypes && constructor.isLocalType()) || (conf.anonymous && constructor.isAnonymous())
|
||||
if (!needApproximate) return null
|
||||
val superConstructor = constructor.supertypes().first().typeConstructor()
|
||||
val typeCheckerContext = newTypeCheckerState(
|
||||
|
||||
+6
@@ -25,6 +25,12 @@ open class TypeApproximatorConfiguration {
|
||||
open val intersectionTypesInContravariantPositions = false
|
||||
open val localTypes = false
|
||||
|
||||
/**
|
||||
* Whether to approximate anonymous type. This flag does not have any effect if `localTypes` is true because all anonymous types are
|
||||
* local.
|
||||
*/
|
||||
open val anonymous = false
|
||||
|
||||
open val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean = { false }
|
||||
open fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean =
|
||||
true // false means that this type we can leave as is
|
||||
|
||||
Reference in New Issue
Block a user