File tree 3 files changed +22
-3
lines changed
compiler/src/dotty/tools/dotc
3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -1464,7 +1464,10 @@ object desugar {
1464
1464
val param = makeSyntheticParameter(
1465
1465
tpt =
1466
1466
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 )
1468
1471
def selector (n : Int ) =
1469
1472
if (isGenericTuple) Apply (Select (refOfDef(param), nme.apply), Literal (Constant (n)))
1470
1473
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 {
1923
1923
/** The shape of given tree as a type; cannot handle named arguments. */
1924
1924
def typeShape (tree : untpd.Tree ): Type = tree match {
1925
1925
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))
1927
1929
case Match (EmptyTree , _) =>
1928
1930
defn.PartialFunctionClass .typeRef.appliedTo(defn.AnyType :: defn.NothingType :: Nil )
1929
1931
case _ =>
@@ -2232,7 +2234,7 @@ trait Applications extends Compatibility {
2232
2234
false
2233
2235
val commonFormal =
2234
2236
if (isPartial) defn.PartialFunctionOf (commonParamTypes.head, WildcardType )
2235
- else defn.FunctionOf (commonParamTypes, WildcardType )
2237
+ else defn.FunctionOf (commonParamTypes, WildcardType , isContextual = untpd.isContextualClosure(arg) )
2236
2238
overload.println(i " pretype arg $arg with expected type $commonFormal" )
2237
2239
if (commonParamTypes.forall(isFullyDefined(_, ForceDegree .flipBottom)))
2238
2240
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