/* Ċ Ġ* ĠCopyright Ġ 2 0 1 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . Ġand ĠKotlin ĠProgramming ĠLanguage Ġcontributors . Ċ Ġ* ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe Ġlicense / LICENSE . txt Ġfile . Ċ Ġ*/ Ċ Ċ package Ġorg . jetbrains . kotlin . resolve . calls . inference . components Ċ Ċ import Ġorg . jetbrains . kotlin . config . Language Feature Ċ import Ġorg . jetbrains . kotlin . config . Language Version Settings Ċ import Ġorg . jetbrains . kotlin . resolve . calls . inference . components . Constraint System Completion Mode . PAR TIAL Ċ import Ġorg . jetbrains . kotlin . resolve . calls . inference . has Recursive Type Parameters With Given Self Type Ċ import Ġorg . jetbrains . kotlin . resolve . calls . inference . is Recursive Type Parameter Ċ import Ġorg . jetbrains . kotlin . resolve . calls . inference . model . Constraint Ċ import Ġorg . jetbrains . kotlin . resolve . calls . inference . model . Declared Upper Bound Constraint Position Ċ import Ġorg . jetbrains . kotlin . resolve . calls . inference . model . Variable With Constraints Ċ import Ġorg . jetbrains . kotlin . resolve . calls . model . Post p oned Resolved Atom Marker Ċ import Ġorg . jetbrains . kotlin . types . model .* Ċ Ċ class ĠVariable Fix ation Finder ( ĊĠĠĠ Ġprivate Ġval Ġtrivial Constraint Type Inference Oracle : ĠT rivial Constraint Type Inference Oracle , ĊĠĠĠ Ġprivate Ġval Ġlanguage Version Settings : ĠLanguage Version Settings , Ċ ) Ġ{ ĊĠĠĠ Ġinterface ĠContext Ġ: ĠType System Inference Extension Context Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnot Fixed Type Variables : ĠMap < Type Constructor Marker , ĠVariable With Constraints > ĊĠĠĠĠĠĠĠ Ġval Ġfixed Type Variables : ĠMap < Type Constructor Marker , ĠKotlin Type Marker > ĊĠĠĠĠĠĠĠ Ġval Ġpost p oned Type Variables : ĠList < Type Variable Marker > ĊĠĠĠĠĠĠĠ Ġfun Ġis Re ified ( variable : ĠType Variable Marker ): ĠBoolean ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġdata Ġclass ĠVariable For Fix ation ( ĊĠĠĠĠĠĠĠ Ġval Ġvariable : ĠType Constructor Marker , ĊĠĠĠĠĠĠĠ Ġval Ġhas Pro per Constraint : ĠBoolean , ĊĠĠĠĠĠĠĠ Ġval Ġhas Only T rivial Pro per Constraint : ĠBoolean Ġ= Ġfalse ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġfun Ġfind First Variable For Fix ation ( ĊĠĠĠĠĠĠĠ Ġc : ĠContext , ĊĠĠĠĠĠĠĠ Ġall Type Variables : ĠList < Type Constructor Marker >, ĊĠĠĠĠĠĠĠ Ġpost p oned Kt Primitives : ĠList < Post p oned Resolved Atom Marker >, ĊĠĠĠĠĠĠĠ Ġcompletion Mode : ĠConstraint System Completion Mode , ĊĠĠĠĠĠĠĠ Ġtop Level Type : ĠKotlin Type Marker , ĊĠĠĠ Ġ): ĠVariable For Fix ation ? Ġ= Ġc . find Type Variable For Fix ation ( all Type Variables , Ġpost p oned Kt Primitives , Ġcompletion Mode , Ġtop Level Type ) ĊĊĠĠĠ Ġenum Ġclass ĠType Variable Fix ation Read iness Ġ{ ĊĠĠĠĠĠĠĠ ĠFOR BID DEN , ĊĠĠĠĠĠĠĠ ĠWITHOUT _ PROPER _ ARGUMENT _ CONSTRAINT , Ġ// Ġproper Ġconstraint Ġfrom Ġarguments Ġ-- Ġnot Ġfrom Ġupper Ġbound Ġfor Ġtype Ġparameters ĊĠĠĠĠĠĠĠ ĠWITH _ COMPLEX _ DEPEND ENCY , Ġ// Ġif Ġtype Ġvariable ĠT Ġhas Ġconstraint Ġwith Ġnon Ġfixed Ġtype Ġvariable Ġinside Ġ( non - top - level ): ĠT Ġ<: ĠFoo < S > ĊĠĠĠĠĠĠĠ ĠWITH _ TR IV IAL _ OR _ NON _ PROPER _ CONSTRAINT S , Ġ// Ġproper Ġtrivial Ġconstraint Ġfrom Ġarguments , ĠNothing Ġ<: ĠT ĊĠĠĠĠĠĠĠ ĠREL ATED _ TO _ ANY _ OUTPUT _ TYPE , ĊĠĠĠĠĠĠĠ ĠFROM _ IN COR POR ATION _ OF _ DECLARE D _ UPPER _ BOUND , ĊĠĠĠĠĠĠĠ ĠREAD Y _ FOR _ FIX ATION _ UPPER , ĊĠĠĠĠĠĠĠ ĠREAD Y _ FOR _ FIX ATION _ LOWER , ĊĠĠĠĠĠĠĠ ĠREAD Y _ FOR _ FIX ATION _ DECLARE D _ UPPER _ BOUND _ WITH _ SELF _ TYPES , ĊĠĠĠĠĠĠĠ ĠREAD Y _ FOR _ FIX ATION , ĊĠĠĠĠĠĠĠ ĠREAD Y _ FOR _ FIX ATION _ RE IFI ED , ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġinference Compatibility Mode Enabled : ĠBoolean ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġlanguage Version Settings . supports Feature ( Language Feature . Inference Compatibility ) ĊĊĠĠĠ Ġprivate Ġval Ġis Type Inference For Self Types Supported : ĠBoolean ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġlanguage Version Settings . supports Feature ( Language Feature . Type Inference On Call sWith Self Types ) ĊĊĠĠĠ Ġprivate Ġfun ĠContext . getType Variable Read iness ( ĊĠĠĠĠĠĠĠ Ġvariable : ĠType Constructor Marker , ĊĠĠĠĠĠĠĠ Ġdependency Provider : ĠType Variable Dependency Information Provider , ĊĠĠĠ Ġ): ĠType Variable Fix ation Read iness Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠĠĠ Ġ! not Fixed Type Variables . contains ( variable ) Ġ|| ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdependency Provider . is Variable Related To TopLevel Type ( variable ) Ġ-> ĠType Variable Fix ation Read iness . FOR BID DEN ĊĠĠĠĠĠĠĠ Ġis Type Inference For Self Types Supported Ġ&& Ġhas Only Declared Upper Bound Self Types ( variable ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠType Variable Fix ation Read iness . READY _ FOR _ FIX ATION _ DECLARE D _ UPPER _ BOUND _ WITH _ SELF _ TYPES ĊĠĠĠĠĠĠĠ Ġ! variable Has Pro per Argument Constraints ( variable ) Ġ-> ĠType Variable Fix ation Read iness . WITHOUT _ PROPER _ ARGUMENT _ CONSTRAINT ĊĠĠĠĠĠĠĠ Ġhas Dependency To Other Type Variables ( variable ) Ġ-> ĠType Variable Fix ation Read iness . WITH _ COMPLEX _ DEPEND ENCY ĊĠĠĠĠĠĠĠ Ġvariable Has T rivial Or Non Pro per Constraints ( variable ) Ġ-> ĠType Variable Fix ation Read iness . WITH _ TR IV IAL _ OR _ NON _ PROPER _ CONSTRAINT S ĊĠĠĠĠĠĠĠ Ġdependency Provider . is Variable Related To Any OutputType ( variable ) Ġ-> ĠType Variable Fix ation Read iness . RELATED _ TO _ ANY _ OUTPUT _ TYPE ĊĠĠĠĠĠĠĠ Ġvariable Has Only In corpor ated Constraints From Declared Upper Bound ( variable ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠType Variable Fix ation Read iness . FROM _ IN COR POR ATION _ OF _ DECLARE D _ UPPER _ BOUND ĊĠĠĠĠĠĠĠ Ġis Re ified ( variable ) Ġ-> ĠType Variable Fix ation Read iness . READY _ FOR _ FIX ATION _ RE IFI ED ĊĠĠĠĠĠĠĠ Ġinference Compatibility Mode Enabled Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvariable Has Lower Non Nothing Pro per Constraint ( variable ) Ġ-> ĠType Variable Fix ation Read iness . READY _ FOR _ FIX ATION _ LOWER ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> ĠType Variable Fix ation Read iness . READY _ FOR _ FIX ATION _ UPPER ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġ-> ĠType Variable Fix ation Read iness . READY _ FOR _ FIX ATION ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġis Type Variable Has Pro per Constraint ( ĊĠĠĠĠĠĠĠ Ġcontext : ĠContext , ĊĠĠĠĠĠĠĠ Ġtype Variable : ĠType Constructor Marker , ĊĠĠĠ Ġ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġwith ( context ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdependency Provider Ġ= ĠType Variable Dependency Information Provider ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnot Fixed Type Variables , Ġempty List (), Ġtop Level Type Ġ= Ġnull , Ġcontext ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( getType Variable Read iness ( type Variable , Ġdependency Provider )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠType Variable Fix ation Read iness . FOR BID DEN , ĠType Variable Fix ation Read iness . WITHOUT _ PROPER _ ARGUMENT _ CONSTRAINT Ġ-> Ġfalse ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . variable Has T rivial Or Non Pro per Constraints ( variable : ĠType Constructor Marker ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġnot Fixed Type Variables [ variable ]?. constraints ?. all Ġ{ Ġconstraint Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġis Pro per Constraint Ġ= Ġis Pro per Argument Constraint ( constraint ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Pro per Constraint Ġ&& Ġtrivial Constraint Type Inference Oracle . isNot Inter esting Constraint ( constraint ) Ġ|| Ġ! is Pro per Constraint ĊĠĠĠĠĠĠĠ Ġ} Ġ?: Ġfalse ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . variable Has Only In corpor ated Constraints From Declared Upper Bound ( variable : ĠType Constructor Marker ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconstraints Ġ= Ġnot Fixed Type Variables [ variable ]?. constraints Ġ?: Ġreturn Ġfalse ĊĊĠĠĠĠĠĠĠ Ġreturn Ġconstraints . filter Ġ{ Ġis Pro per Argument Constraint ( it ) Ġ}. all Ġ{ Ġit . position . is From Declared Upper Bound Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . find Type Variable For Fix ation ( ĊĠĠĠĠĠĠĠ Ġall Type Variables : ĠList < Type Constructor Marker >, ĊĠĠĠĠĠĠĠ Ġpost p oned Arguments : ĠList < Post p oned Resolved Atom Marker >, ĊĠĠĠĠĠĠĠ Ġcompletion Mode : ĠConstraint System Completion Mode , ĊĠĠĠĠĠĠĠ Ġtop Level Type : ĠKotlin Type Marker , ĊĠĠĠ Ġ): ĠVariable For Fix ation ? Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( all Type Variables . isEmpty ()) Ġreturn Ġnull ĊĊĠĠĠĠĠĠĠ Ġval Ġdependency Provider Ġ= ĠType Variable Dependency Information Provider ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnot Fixed Type Variables , Ġpost p oned Arguments , Ġtop Level Type . take If Ġ{ Ġcompletion Mode Ġ== ĠPAR TIAL Ġ}, Ġthis ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcandidate Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġall Type Variables . max By OrNull Ġ{ ĠgetType Variable Read iness ( it , Ġdependency Provider ) Ġ} Ġ?: Ġreturn Ġnull ĊĊĠĠĠĠĠĠĠ Ġreturn Ġwhen Ġ( getType Variable Read iness ( candidate , Ġdependency Provider )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠType Variable Fix ation Read iness . FOR BID DEN Ġ-> Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠ ĠType Variable Fix ation Read iness . WITHOUT _ PROPER _ ARGUMENT _ CONSTRAINT Ġ-> ĠVariable For Fix ation ( candidate , Ġfalse ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠType Variable Fix ation Read iness . WITH _ TR IV IAL _ OR _ NON _ PROPER _ CONSTRAINT S Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠVariable For Fix ation ( candidate , Ġhas Pro per Constraint Ġ= Ġtrue , Ġhas Only T rivial Pro per Constraint Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> ĠVariable For Fix ation ( candidate , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . has Dependency To Other Type Variables ( type Variable : ĠType Constructor Marker ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġfor Ġ( constraint Ġin Ġnot Fixed Type Variables [ type Variable ]?. constraints Ġ?: Ġreturn Ġfalse ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdependency Presence Condition Ġ= Ġ{ Ġtype : ĠKotlin Type Marker Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtype . type Constructor () Ġ!= Ġtype Variable Ġ&& Ġnot Fixed Type Variables . containsKey ( type . type Constructor ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( constraint . type . lower Bound If Flex ible (). arguments Count () Ġ!= Ġ 0 Ġ&& Ġconstraint . type . contains ( dependency Presence Condition )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġfalse ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . variable Has Pro per Argument Constraints ( variable : ĠType Constructor Marker ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconstraints Ġ= Ġnot Fixed Type Variables [ variable ]?. constraints Ġ?: Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġ// Ġtemporary Ġhack Ġto Ġfail Ġcalls Ġwhich Ġcontain Ġcallable Ġreferences Ġresolved Ġthough ĠO I Ġwith Ġun in ferred Ġtype Ġparameters ĊĠĠĠĠĠĠĠ Ġval Ġare There Constraints With Un in ferred Type Parameter Ġ= Ġconstraints . any Ġ{ Ġc Ġ-> Ġc . type . contains Ġ{ Ġit . is Un in ferred Parameter () Ġ} Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġconstraints . any Ġ{ Ġis Pro per Argument Constraint ( it ) Ġ} Ġ&& Ġ! are There Constraints With Un in ferred Type Parameter ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . is Pro per Argument Constraint ( c : ĠConstraint ) Ġ= ĊĠĠĠĠĠĠĠ Ġis Pro per Type ( c . type ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ&& Ġc . position . initial Constraint . position Ġ! is ĠDecl ared Upper Bound Constraint Position < *> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ&& Ġ! c . isNull ability Constraint ĊĊĠĠĠ Ġprivate Ġfun ĠContext . is Pro per Type ( type : ĠKotlin Type Marker ): ĠBoolean Ġ= ĊĠĠĠĠĠĠĠ Ġis Pro per Type For Fix ation ( type ) Ġ{ Ġt Ġ-> Ġ! t . contains Ġ{ Ġnot Fixed Type Variables . containsKey ( it . type Constructor ()) Ġ} Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . is Re ified ( variable : ĠType Constructor Marker ): ĠBoolean Ġ= ĊĠĠĠĠĠĠĠ Ġnot Fixed Type Variables [ variable ]?. type Variable ?. let Ġ{ Ġis Re ified ( it ) Ġ} Ġ?: Ġfalse ĊĊĠĠĠ Ġprivate Ġfun ĠContext . variable Has Lower Non Nothing Pro per Constraint ( variable : ĠType Constructor Marker ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconstraints Ġ= Ġnot Fixed Type Variables [ variable ]?. constraints Ġ?: Ġreturn Ġfalse ĊĊĠĠĠĠĠĠĠ Ġreturn Ġconstraints . any Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . kind . is Lower () Ġ&& Ġis Pro per Argument Constraint ( it ) Ġ&& Ġ! it . type . type Constructor (). is Nothing Constructor () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠContext . has Only Declared Upper Bound Self Types ( variable : ĠType Constructor Marker ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconstraints Ġ= Ġnot Fixed Type Variables [ variable ]?. constraints Ġ?: Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġreturn Ġconstraints . isNotEmpty () Ġ&& Ġconstraints . all Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtype Constructor Ġ= Ġit . type . type Constructor () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . position . from Ġis ĠDecl ared Upper Bound Constraint Position < *> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ&& Ġ( has Recursive Type Parameters With Given Self Type ( type Constructor ) Ġ|| Ġis Recursive Type Parameter ( type Constructor )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ inline Ġfun ĠType System Inference Extension Context . is Pro per Type For Fix ation ( type : ĠKotlin Type Marker , Ġis Pro per : Ġ( Kotlin Type Marker ) Ġ-> ĠBoolean ) Ġ= ĊĠĠĠ Ġis Pro per ( type ) Ġ&& Ġextract Projection s ForAll Capt ured Types ( type ). all ( is Pro per ) Ċ Ċ @ Opt In ( Experimental Std lib Api :: class ) Ċ fun ĠType System Inference Extension Context . extract Projection s ForAll Capt ured Types ( base Type : ĠKotlin Type Marker ): ĠSet < Kotlin Type Marker > Ġ{ ĊĠĠĠ Ġval Ġsimple BaseType Ġ= Ġbase Type . as Simple Type () ĊĊĠĠĠ Ġreturn Ġbuild Set Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġprojection Type Ġ= Ġif Ġ( simple BaseType Ġis ĠCapt ured Type Marker ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtype Argument Ġ= Ġsimple BaseType . type Constructor Projection (). take If Ġ{ Ġ! it . is Star Projection () Ġ} Ġ?: Ġreturn @ build Set ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtype Argument . getType (). also (:: add ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġbase Type ĊĠĠĠĠĠĠĠ Ġval Ġarguments Count Ġ= Ġprojection Type . arguments Count (). take If Ġ{ Ġit Ġ!= Ġ 0 Ġ} Ġ?: Ġreturn @ build Set ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 0 Ġuntil Ġarguments Count ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtype Argument Ġ= Ġprojection Type . get Argument ( i ). take If Ġ{ Ġ! it . is Star Projection () Ġ} Ġ?: Ġcontinue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd All ( extract Projection s ForAll Capt ured Types ( type Argument . getType ())) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠType System Inference Extension Context . contains Type Variable ( type : ĠKotlin Type Marker , Ġtype Variable : ĠType Constructor Marker ): ĠBoolean Ġ{ ĊĠĠĠ Ġif Ġ( type . contains Ġ{ Ġit . type Constructor () Ġ== Ġtype Variable Ġ}) Ġreturn Ġtrue ĊĊĠĠĠ Ġval Ġtype Projection s Ġ= Ġextract Projection s ForAll Capt ured Types ( type ) ĊĊĠĠĠ Ġreturn Ġtype Projection s . any Ġ{ Ġtype Projection sType Ġ-> ĊĠĠĠĠĠĠĠ Ġtype Projection sType . contains Ġ{ Ġit . type Constructor () Ġ== Ġtype Variable Ġ} ĊĠĠĠ Ġ} Ċ } Ċ