File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -1464,7 +1464,10 @@ object desugar {
14641464 val param = makeSyntheticParameter(
14651465 tpt =
14661466 if params.exists(_.tpt.isEmpty) then TypeTree ()
1467- else Tuple (params.map(_.tpt)))
1467+ else Tuple (params.map(_.tpt)),
1468+ flags =
1469+ if params.nonEmpty && params.head.mods.is(Given ) then SyntheticTermParam | Given
1470+ else SyntheticTermParam )
14681471 def selector (n : Int ) =
14691472 if (isGenericTuple) Apply (Select (refOfDef(param), nme.apply), Literal (Constant (n)))
14701473 else Select (refOfDef(param), nme.selectorName(n))
Original file line number Diff line number Diff line change @@ -1923,7 +1923,9 @@ trait Applications extends Compatibility {
19231923 /** The shape of given tree as a type; cannot handle named arguments. */
19241924 def typeShape (tree : untpd.Tree ): Type = tree match {
19251925 case untpd.Function (args, body) =>
1926- defn.FunctionOf (args map Function .const(defn.AnyType ), typeShape(body))
1926+ defn.FunctionOf (
1927+ args.map(Function .const(defn.AnyType )), typeShape(body),
1928+ isContextual = untpd.isContextualClosure(tree))
19271929 case Match (EmptyTree , _) =>
19281930 defn.PartialFunctionClass .typeRef.appliedTo(defn.AnyType :: defn.NothingType :: Nil )
19291931 case _ =>
@@ -2232,7 +2234,7 @@ trait Applications extends Compatibility {
22322234 false
22332235 val commonFormal =
22342236 if (isPartial) defn.PartialFunctionOf (commonParamTypes.head, WildcardType )
2235- else defn.FunctionOf (commonParamTypes, WildcardType )
2237+ else defn.FunctionOf (commonParamTypes, WildcardType , isContextual = untpd.isContextualClosure(arg) )
22362238 overload.println(i " pretype arg $arg with expected type $commonFormal" )
22372239 if (commonParamTypes.forall(isFullyDefined(_, ForceDegree .flipBottom)))
22382240 withMode(Mode .ImplicitsEnabled ) {
Original file line number Diff line number Diff line change 1+ import scala .annotation .targetName
2+
3+ trait Ctx
4+
5+ def foo (f : Ctx => Int ) = ???
6+
7+ @ targetName(" fooContextual" )
8+ def foo (f : Ctx ?=> Int ) = ???
9+
10+ def bar1 = foo(ctx => 123 )
11+ def bar2 = foo((ctx : Ctx ) => 123 )
12+ def bar3 = foo(ctx ?=> 123 )
13+ def bar4 = foo((ctx : Ctx ) ?=> 123 )
14+ // def bar5 = foo(123) does not work
You can’t perform that action at this time.
0 commit comments