diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index d4a1126c5df7..b3da00fa6f63 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -298,7 +298,7 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] def isFunctionWithUnknownParamType(tree: Tree): Boolean = functionWithUnknownParamType(tree).isDefined - /** Is `tree` an implicit function or closure, possibly nested in a block? */ + /** Is `tree` an context function or closure, possibly nested in a block? */ def isContextualClosure(tree: Tree)(implicit ctx: Context): Boolean = unsplice(tree) match { case tree: FunctionWithMods => tree.mods.is(Given) case Function((param: untpd.ValDef) :: _, _) => param.mods.is(Given) @@ -307,7 +307,7 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] case Block(DefDef(nme.ANON_FUN, _, params :: _, _, _) :: Nil, cl: Closure) => params match { case param :: _ => param.mods.is(Given) - case Nil => cl.tpt.eq(untpd.ContextualEmptyTree) || defn.isImplicitFunctionType(cl.tpt.typeOpt) + case Nil => cl.tpt.eq(untpd.ContextualEmptyTree) || defn.isContextFunctionType(cl.tpt.typeOpt) } case _ => false } diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 66ee24fc3898..35349f6aa5c1 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -76,7 +76,7 @@ class Definitions { newClassSymbol(ScalaPackageClass, name, Artifact, completer).entered } - /** The trait FunctionN, ImplicitFunctionN, ErasedFunctionN or ErasedImplicitFunction, for some N + /** The trait FunctionN, ContextFunctionN, ErasedFunctionN or ErasedContextFunction, for some N * @param name The name of the trait to be created * * FunctionN traits follow this template: @@ -89,9 +89,9 @@ class Definitions { * standard library, but without `tupled` and `curried` methods and without * a `toString`. * - * ImplicitFunctionN traits follow this template: + * ContextFunctionN traits follow this template: * - * trait ImplicitFunctionN[T0,...,T{N-1}, R] extends Object { + * trait ContextFunctionN[T0,...,T{N-1}, R] extends Object { * def apply(given $x0: T0, ..., $x{N_1}: T{N-1}): R * } * @@ -101,13 +101,13 @@ class Definitions { * def apply(erased $x0: T0, ..., $x{N_1}: T{N-1}): R * } * - * ErasedImplicitFunctionN traits follow this template: + * ErasedContextFunctionN traits follow this template: * - * trait ErasedImplicitFunctionN[T0,...,T{N-1}, R] extends Object { + * trait ErasedContextFunctionN[T0,...,T{N-1}, R] extends Object { * def apply (given erased $x0: T0, ..., $x{N_1}: T{N-1}): R * } * - * ErasedFunctionN and ErasedImplicitFunctionN erase to Function0. + * ErasedFunctionN and ErasedContextFunctionN erase to Function0. */ def newFunctionNTrait(name: TypeName): ClassSymbol = { val completer = new LazyType { @@ -122,7 +122,7 @@ class Definitions { val resParamRef = enterTypeParam(cls, paramNamePrefix ++ "R", Covariant, decls).typeRef val methodType = MethodType.companion( isJava = false, - isContextual = name.isImplicitFunction, + isContextual = name.isContextFunction, isImplicit = false, isErased = name.isErasedFunction) decls.enter(newMethod(cls, nme.apply, methodType(argParamRefs, resParamRef), Deferred)) @@ -131,7 +131,7 @@ class Definitions { } } val flags0 = Trait | NoInits - val flags = if (name.isImplicitFunction) flags0 | Final else flags0 + val flags = if (name.isContextFunction) flags0 | Final else flags0 newClassSymbol(ScalaPackageClass, name, flags, completer) } @@ -878,7 +878,7 @@ class Definitions { if (isFunctionClass(tsym)) { val targs = ft.dealias.argInfos if (targs.isEmpty) None - else Some(targs.init, targs.last, tsym.name.isImplicitFunction, tsym.name.isErasedFunction) + else Some(targs.init, targs.last, tsym.name.isContextFunction, tsym.name.isErasedFunction) } else None } @@ -998,9 +998,9 @@ class Definitions { def FunctionClass(n: Int, isContextual: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): Symbol = if (isContextual && isErased) - ctx.requiredClass("scala.ErasedImplicitFunction" + n.toString) + ctx.requiredClass("scala.ErasedContextFunction" + n.toString) else if (isContextual) - ctx.requiredClass("scala.ImplicitFunction" + n.toString) + ctx.requiredClass("scala.ContextFunction" + n.toString) else if (isErased) ctx.requiredClass("scala.ErasedFunction" + n.toString) else if (n <= MaxImplementedFunctionArity) @@ -1047,28 +1047,28 @@ class Definitions { /** Is a function class. * - FunctionXXL * - FunctionN for N >= 0 - * - ImplicitFunctionN for N >= 0 + * - ContextFunctionN for N >= 0 * - ErasedFunctionN for N > 0 - * - ErasedImplicitFunctionN for N > 0 + * - ErasedContextFunctionN for N > 0 */ def isFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isFunction - /** Is an implicit function class. - * - ImplicitFunctionN for N >= 0 - * - ErasedImplicitFunctionN for N > 0 + /** Is an context function class. + * - ContextFunctionN for N >= 0 + * - ErasedContextFunctionN for N > 0 */ - def isImplicitFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isImplicitFunction + def isContextFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isContextFunction /** Is an erased function class. * - ErasedFunctionN for N > 0 - * - ErasedImplicitFunctionN for N > 0 + * - ErasedContextFunctionN for N > 0 */ def isErasedFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isErasedFunction /** Is either FunctionXXL or a class that will be erased to FunctionXXL * - FunctionXXL * - FunctionN for N >= 22 - * - ImplicitFunctionN for N >= 22 + * - ContextFunctionN for N >= 22 */ def isXXLFunctionClass(cls: Symbol): Boolean = { val name = scalaClassName(cls) @@ -1077,9 +1077,9 @@ class Definitions { /** Is a synthetic function class * - FunctionN for N > 22 - * - ImplicitFunctionN for N >= 0 + * - ContextFunctionN for N >= 0 * - ErasedFunctionN for N > 0 - * - ErasedImplicitFunctionN for N > 0 + * - ErasedContextFunctionN for N > 0 */ def isSyntheticFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isSyntheticFunction @@ -1093,8 +1093,8 @@ class Definitions { /** Returns the erased class of the function class `cls` * - FunctionN for N > 22 becomes FunctionXXL * - FunctionN for 22 > N >= 0 remains as FunctionN - * - ImplicitFunctionN for N > 22 becomes FunctionXXL - * - ImplicitFunctionN for N <= 22 becomes FunctionN + * - ContextFunctionN for N > 22 becomes FunctionXXL + * - ContextFunctionN for N <= 22 becomes FunctionN * - ErasedFunctionN becomes Function0 * - ImplicitErasedFunctionN becomes Function0 * - anything else becomes a NoSymbol @@ -1110,8 +1110,8 @@ class Definitions { /** Returns the erased type of the function class `cls` * - FunctionN for N > 22 becomes FunctionXXL * - FunctionN for 22 > N >= 0 remains as FunctionN - * - ImplicitFunctionN for N > 22 becomes FunctionXXL - * - ImplicitFunctionN for N <= 22 becomes FunctionN + * - ContextFunctionN for N > 22 becomes FunctionXXL + * - ContextFunctionN for N <= 22 becomes FunctionN * - ErasedFunctionN becomes Function0 * - ImplicitErasedFunctionN becomes Function0 * - anything else becomes a NoType @@ -1194,7 +1194,7 @@ class Definitions { def isProductSubType(tp: Type)(implicit ctx: Context): Boolean = tp.derivesFrom(ProductClass) - /** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN + /** Is `tp` (an alias) of either a scala.FunctionN or a scala.ContextFunctionN * instance? */ def isNonRefinedFunction(tp: Type)(implicit ctx: Context): Boolean = { @@ -1203,7 +1203,7 @@ class Definitions { arity >= 0 && isFunctionClass(sym) && - tp.isRef(FunctionType(arity, sym.name.isImplicitFunction, sym.name.isErasedFunction).typeSymbol) && + tp.isRef(FunctionType(arity, sym.name.isContextFunction, sym.name.isErasedFunction).typeSymbol) && !tp.isInstanceOf[RefinedType] } @@ -1251,24 +1251,24 @@ class Definitions { def functionArity(tp: Type)(implicit ctx: Context): Int = tp.dropDependentRefinement.dealias.argInfos.length - 1 - /** Return underlying immplicit function type (i.e. instance of an ImplicitFunctionN class) + /** Return underlying context function type (i.e. instance of an ContextFunctionN class) * or NoType if none exists. The following types are considered as underlying types: * - the alias of an alias type * - the instance or origin of a TypeVar (i.e. the result of a stripTypeVar) * - the upper bound of a TypeParamRef in the current constraint */ - def asImplicitFunctionType(tp: Type)(implicit ctx: Context): Type = + def asContextFunctionType(tp: Type)(implicit ctx: Context): Type = tp.stripTypeVar.dealias match { case tp1: TypeParamRef if ctx.typerState.constraint.contains(tp1) => - asImplicitFunctionType(ctx.typeComparer.bounds(tp1).hiBound) + asContextFunctionType(ctx.typeComparer.bounds(tp1).hiBound) case tp1 => - if (isFunctionType(tp1) && tp1.typeSymbol.name.isImplicitFunction) tp1 + if (isFunctionType(tp1) && tp1.typeSymbol.name.isContextFunction) tp1 else NoType } - /** Is `tp` an implicit function type? */ - def isImplicitFunctionType(tp: Type)(implicit ctx: Context): Boolean = - asImplicitFunctionType(tp).exists + /** Is `tp` an context function type? */ + def isContextFunctionType(tp: Type)(implicit ctx: Context): Boolean = + asContextFunctionType(tp).exists def isErasedFunctionType(tp: Type)(implicit ctx: Context): Boolean = isFunctionType(tp) && tp.dealias.typeSymbol.name.isErasedFunction diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index d13edc3e6cac..b7848d4795a7 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -150,38 +150,38 @@ object NameOps { def functionArity: Int = functionArityFor(str.Function) max - functionArityFor(str.ImplicitFunction) max { + functionArityFor(str.ContextFunction) max { val n = functionArityFor(str.ErasedFunction) max - functionArityFor(str.ErasedImplicitFunction) + functionArityFor(str.ErasedContextFunction) if (n == 0) -1 else n } - /** Is a function name, i.e one of FunctionXXL, FunctionN, ImplicitFunctionN for N >= 0 or ErasedFunctionN, ErasedImplicitFunctionN for N > 0 + /** Is a function name, i.e one of FunctionXXL, FunctionN, ContextFunctionN for N >= 0 or ErasedFunctionN, ErasedContextFunctionN for N > 0 */ def isFunction: Boolean = (name eq tpnme.FunctionXXL) || functionArity >= 0 - /** Is an implicit function name, i.e one of ImplicitFunctionN for N >= 0 or ErasedImplicitFunctionN for N > 0 + /** Is an context function name, i.e one of ContextFunctionN for N >= 0 or ErasedContextFunctionN for N > 0 */ - def isImplicitFunction: Boolean = - functionArityFor(str.ImplicitFunction) >= 0 || - functionArityFor(str.ErasedImplicitFunction) > 0 + def isContextFunction: Boolean = + functionArityFor(str.ContextFunction) >= 0 || + functionArityFor(str.ErasedContextFunction) > 0 - /** Is an erased function name, i.e. one of ErasedFunctionN, ErasedImplicitFunctionN for N > 0 + /** Is an erased function name, i.e. one of ErasedFunctionN, ErasedContextFunctionN for N > 0 */ def isErasedFunction: Boolean = functionArityFor(str.ErasedFunction) > 0 || - functionArityFor(str.ErasedImplicitFunction) > 0 + functionArityFor(str.ErasedContextFunction) > 0 /** Is a synthetic function name, i.e. one of * - FunctionN for N > 22 - * - ImplicitFunctionN for N >= 0 + * - ContextFunctionN for N >= 0 * - ErasedFunctionN for N > 0 - * - ErasedImplicitFunctionN for N > 0 + * - ErasedContextFunctionN for N > 0 */ def isSyntheticFunction: Boolean = functionArityFor(str.Function) > MaxImplementedFunctionArity || - functionArityFor(str.ImplicitFunction) >= 0 || + functionArityFor(str.ContextFunction) >= 0 || isErasedFunction /** Parsed function arity for function with some specific prefix */ diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index 90671c410113..7173ee30409d 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -35,8 +35,8 @@ object StdNames { final val Function = "Function" final val ErasedFunction = "ErasedFunction" - final val ImplicitFunction = "ImplicitFunction" - final val ErasedImplicitFunction = "ErasedImplicitFunction" + final val ContextFunction = "ContextFunction" + final val ErasedContextFunction = "ErasedContextFunction" final val AbstractFunction = "AbstractFunction" final val Tuple = "Tuple" final val Product = "Product" diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index c367a538f7aa..1d5b4864f036 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -413,7 +413,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean * - For a typeref scala.Any, scala.AnyVal, scala.Singleton, scala.Tuple, or scala.*: : |java.lang.Object| * - For a typeref scala.Unit, |scala.runtime.BoxedUnit|. * - For a typeref scala.FunctionN, where N > MaxImplementedFunctionArity, scala.FunctionXXL - * - For a typeref scala.ImplicitFunctionN, | scala.FunctionN | + * - For a typeref scala.ContextFunctionN, | scala.FunctionN | * - For a typeref P.C where C refers to a class, # C. * - For a typeref P.C where C refers to an alias type, the erasure of C's alias. * - For a typeref P.C where C refers to an abstract type, the erasure of C's upper bound. diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 8c9e1fe1e837..58ed79ce1705 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4627,7 +4627,7 @@ object Types { case et: ExprType => true case _ => false } - // `ImplicitFunctionN` does not have constructors + // `ContextFunctionN` does not have constructors val ctor = tp.cls.primaryConstructor if (!ctor.exists || zeroParams(ctor.info)) tp else NoType @@ -4657,7 +4657,7 @@ object Types { if (absMems.size == 1) absMems.head.info match { case mt: MethodType if !mt.isParamDependent && - !defn.isImplicitFunctionType(mt.resultType) => + !defn.isContextFunctionType(mt.resultType) => val cls = tp.classSymbol // Given a SAM type such as: diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 9ebebd8c19ea..e6937033c68c 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -195,7 +195,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case tp @ AppliedType(tycon, args) => val cls = tycon.typeSymbol if (tycon.isRepeatedParam) toTextLocal(args.head) ~ "*" - else if (defn.isFunctionClass(cls)) toTextFunction(args, cls.name.isImplicitFunction, cls.name.isErasedFunction) + else if (defn.isFunctionClass(cls)) toTextFunction(args, cls.name.isContextFunction, cls.name.isErasedFunction) else if (tp.tupleArity >= 2 && !printDebug) toTextTuple(tp.tupleElementTypes) else if (isInfixType(tp)) { val l :: r :: Nil = args diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala index 46441c2cda53..97d6f6057989 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala @@ -1191,8 +1191,8 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def Type_isFunctionType(self: Type)(given Context): Boolean = defn.isFunctionType(self) - def Type_isImplicitFunctionType(self: Type)(given Context): Boolean = - defn.isImplicitFunctionType(self) + def Type_isContextFunctionType(self: Type)(given Context): Boolean = + defn.isContextFunctionType(self) def Type_isErasedFunctionType(self: Type)(given Context): Boolean = defn.isErasedFunctionType(self) diff --git a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala index 25c5842bbf47..9f93af68cf02 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala @@ -36,7 +36,7 @@ class ExpandSAMs extends MiniPhase { tpt.tpe match { case NoType => tree // it's a plain function - case tpe if defn.isImplicitFunctionType(tpe) => + case tpe if defn.isContextFunctionType(tpe) => tree case tpe @ SAMType(_) if tpe.isRef(defn.PartialFunctionClass) => val tpe1 = checkRefinements(tpe, fn) diff --git a/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala b/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala index bee4d38e2baf..a7a102c1981c 100644 --- a/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala +++ b/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala @@ -85,7 +85,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisPh /** Transform `qual.apply` occurrences according to rewrite rule (2) above */ override def transformSelect(tree: Select)(implicit ctx: Context): Tree = if (tree.name == nme.apply && - defn.isImplicitFunctionType(tree.qualifier.tpe.widen) && + defn.isContextFunctionType(tree.qualifier.tpe.widen) && needsImplicitShortcut(tree.qualifier.symbol)) { def directQual(tree: Tree): Tree = tree match { case Apply(fn, args) => cpy.Apply(tree)(directQual(fn), args) @@ -165,7 +165,7 @@ object ShortcutImplicits { */ def needsImplicitShortcut(sym: Symbol)(implicit ctx: Context): Boolean = sym.is(Method, butNot = Accessor) && - defn.isImplicitFunctionType(sym.info.finalResultType) && + defn.isContextFunctionType(sym.info.finalResultType) && defn.functionArity(sym.info.finalResultType) > 0 && !sym.isAnonymousFunction && (specializeMonoTargets || !sym.isEffectivelyFinal || sym.allOverriddenSymbols.nonEmpty) diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index 8a60da65bb5e..7a41c81bd288 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -313,7 +313,7 @@ object Splicer { } def getDirectName(tp: Type, name: TermName): TermName = tp.widenDealias match { - case tp: AppliedType if defn.isImplicitFunctionType(tp) => + case tp: AppliedType if defn.isContextFunctionType(tp) => getDirectName(tp.args.last, NameKinds.DirectMethodName(name)) case _ => name } @@ -468,8 +468,8 @@ object Splicer { else java.lang.Class.forName(javaSig(param), false, classLoader) } def getExtraParams(tp: Type): List[Type] = tp.widenDealias match { - case tp: AppliedType if defn.isImplicitFunctionType(tp) => - // Call implicit function type direct method + case tp: AppliedType if defn.isContextFunctionType(tp) => + // Call context function type direct method tp.args.init.map(arg => TypeErasure.erasure(arg)) ::: getExtraParams(tp.args.last) case _ => Nil } @@ -496,7 +496,7 @@ object Splicer { private object Call0 { def unapply(arg: Tree)(implicit ctx: Context): Option[(RefTree, List[List[Tree]])] = arg match { - case Select(Call0(fn, args), nme.apply) if defn.isImplicitFunctionType(fn.tpe.widenDealias.finalResultType) => + case Select(Call0(fn, args), nme.apply) if defn.isContextFunctionType(fn.tpe.widenDealias.finalResultType) => Some((fn, args)) case fn: RefTree => Some((fn, Nil)) case Apply(f @ Call0(fn, args1), args2) => diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index f30c3872cd8e..73b23b6f35df 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -741,7 +741,7 @@ trait Implicits { self: Typer => (formal, span) => implicit ctx => formal match { case AppliedType(_, funArgs @ fun :: tupled :: Nil) => def functionTypeEqual(baseFun: Type, actualArgs: List[Type], actualRet: Type, expected: Type) = - expected =:= defn.FunctionOf(actualArgs, actualRet, defn.isImplicitFunctionType(baseFun), defn.isErasedFunctionType(baseFun)) + expected =:= defn.FunctionOf(actualArgs, actualRet, defn.isContextFunctionType(baseFun), defn.isErasedFunctionType(baseFun)) val arity: Int = if (defn.isErasedFunctionType(fun) || defn.isErasedFunctionType(fun)) -1 // TODO support? else if (defn.isFunctionType(fun)) diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index ec1a715497c5..ea7a05abbd9a 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -588,7 +588,7 @@ object ProtoTypes { case et: ExprType => normalize(et.resultType, pt) case wtp => - val iftp = defn.asImplicitFunctionType(wtp) + val iftp = defn.asContextFunctionType(wtp) if (iftp.exists) normalize(iftp.dropDependentRefinement.argInfos.last, pt) else tp } } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 256aad382939..cb770d5619f2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2194,7 +2194,7 @@ class Typer extends Namer case _ => typedUnadapted(desugar(tree), pt, locked) } - val ifpt = defn.asImplicitFunctionType(pt) + val ifpt = defn.asContextFunctionType(pt) val result = if ifpt.exists && xtree.isTerm @@ -2815,7 +2815,7 @@ class Typer extends Namer */ def adaptNoArgsUnappliedMethod(wtp: MethodType, functionExpected: Boolean, arity: Int): Tree = { def isExpandableApply = - defn.isImplicitFunctionClass(tree.symbol.maybeOwner) && functionExpected + defn.isContextFunctionClass(tree.symbol.maybeOwner) && functionExpected /** Is reference to this symbol `f` automatically expanded to `f()`? */ def isAutoApplied(sym: Symbol): Boolean = @@ -2850,17 +2850,17 @@ class Typer extends Namer missingArgs(wtp) } - def isImplicitFunctionRef(wtp: Type): Boolean = wtp match { + def isContextFunctionRef(wtp: Type): Boolean = wtp match { case RefinedType(parent, nme.apply, _) => - isImplicitFunctionRef(parent) // apply refinements indicate a dependent IFT + isContextFunctionRef(parent) // apply refinements indicate a dependent IFT case _ => val underlying = wtp.underlyingClassRef(refinementOK = false) // other refinements are not OK - defn.isImplicitFunctionClass(underlying.classSymbol) + defn.isContextFunctionClass(underlying.classSymbol) } def adaptNoArgsOther(wtp: Type): Tree = { ctx.typeComparer.GADTused = false - if (isImplicitFunctionRef(wtp) && + if (isContextFunctionRef(wtp) && !untpd.isContextualClosure(tree) && !isApplyProto(pt) && pt != AssignProto && @@ -3197,7 +3197,7 @@ class Typer extends Namer * - neither is contextual, or * - the prototype is contextual and the method type is implicit. * The last rule is there for a transition period; it allows to mix `with` applications - * with old-style implicit functions. + * with old-style context functions. * Overridden in `ReTyper`, where all applications are treated the same */ protected def matchingApply(methType: MethodOrPoly, pt: FunProto)(implicit ctx: Context): Boolean = diff --git a/doc-tool/src/dotty/tools/dottydoc/model/factories.scala b/doc-tool/src/dotty/tools/dottydoc/model/factories.scala index 197e75d9b7be..4906fc736b38 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/factories.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/factories.scala @@ -67,7 +67,7 @@ object factories { val cls = tycon.typeSymbol if (defn.isFunctionClass(cls)) - FunctionReference(args.init.map(expandTpe(_, Nil)), expandTpe(args.last), defn.isImplicitFunctionClass(cls)) + FunctionReference(args.init.map(expandTpe(_, Nil)), expandTpe(args.last), defn.isContextFunctionClass(cls)) else if (defn.isTupleClass(cls)) TupleReference(args.map(expandTpe(_, Nil))) else { diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 619eed5edbd9..860eb2818caa 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -1641,11 +1641,11 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => */ def isFunctionType(given ctx: Context): Boolean = internal.Type_isFunctionType(self) - /** Is this type an implicit function type? + /** Is this type an context function type? * * @see `isFunctionType` */ - def isImplicitFunctionType(given ctx: Context): Boolean = internal.Type_isImplicitFunctionType(self) + def isContextFunctionType(given ctx: Context): Boolean = internal.Type_isContextFunctionType(self) /** Is this type an erased function type? * diff --git a/library/src/scala/tasty/reflect/CompilerInterface.scala b/library/src/scala/tasty/reflect/CompilerInterface.scala index 72cbe6fe1736..3b136c451c73 100644 --- a/library/src/scala/tasty/reflect/CompilerInterface.scala +++ b/library/src/scala/tasty/reflect/CompilerInterface.scala @@ -871,11 +871,11 @@ trait CompilerInterface { def Type_isFunctionType(self: Type)(given ctx: Context): Boolean - /** Is this type an implicit function type? + /** Is this type an context function type? * * @see `Type_isFunctionType` */ - def Type_isImplicitFunctionType(self: Type)(given ctx: Context): Boolean + def Type_isContextFunctionType(self: Type)(given ctx: Context): Boolean /** Is this type an erased function type? * diff --git a/library/src/scala/tasty/reflect/SourceCodePrinter.scala b/library/src/scala/tasty/reflect/SourceCodePrinter.scala index fc7a76f30bd6..a722805c91b0 100644 --- a/library/src/scala/tasty/reflect/SourceCodePrinter.scala +++ b/library/src/scala/tasty/reflect/SourceCodePrinter.scala @@ -384,7 +384,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig case Apply(fn, args) => fn match { case Select(This(_), "") => this += "this" // call to constructor inside a constructor - case Select(qual, "apply") if qual.tpe.isImplicitFunctionType => + case Select(qual, "apply") if qual.tpe.isContextFunctionType => printTree(qual) += " given " case _ => printQualTree(fn) } diff --git a/tests/neg/implicit-funs.scala b/tests/neg/implicit-funs.scala index 7941f7b40a3e..e7049644b62b 100644 --- a/tests/neg/implicit-funs.scala +++ b/tests/neg/implicit-funs.scala @@ -1,6 +1,6 @@ trait IF1 extends (Int ?=> Unit) // error abstract class IF2 extends ((Int, String) ?=> Unit) // error -class IF3 extends (ImplicitFunction3[Int, String, Boolean, Unit]) { // error +class IF3 extends (ContextFunction3[Int, String, Boolean, Unit]) { // error def apply(using Int, String, Boolean) = () } diff --git a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala index b96ebac4b87c..86c0d6615bfe 100644 --- a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala +++ b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala @@ -9,11 +9,11 @@ def isFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] } -inline def isImplicitFunctionType[T:Type]: Boolean = ${ isImplicitFunctionTypeImpl('[T]) } +inline def isContextFunctionType[T:Type]: Boolean = ${ isContextFunctionTypeImpl('[T]) } -def isImplicitFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { +def isContextFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} - Expr(tp.unseal.tpe.isImplicitFunctionType) + Expr(tp.unseal.tpe.isContextFunctionType) } diff --git a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/test_2.scala b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/test_2.scala index 7ea0872f1f9e..647711ba7ed9 100644 --- a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/test_2.scala +++ b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/test_2.scala @@ -51,10 +51,10 @@ object Test { // type A = (b: Box) => b.T // assert(isDependentFunctionType[A]) - assert(isImplicitFunctionType[Int ?=> Int]) - assert(!isImplicitFunctionType[Int => Int]) + assert(isContextFunctionType[Int ?=> Int]) + assert(!isContextFunctionType[Int => Int]) // type B = given Set[Int] => Int - // assert(isImplicitFunctionType[B]) + // assert(isContextFunctionType[B]) assert(isErasedFunctionType[(erased Int) => Int]) assert(!isErasedFunctionType[Int => Int]) diff --git a/tests/run-macros/tasty-definitions-1.check b/tests/run-macros/tasty-definitions-1.check index d16dd6d1796f..9262395615d6 100644 --- a/tests/run-macros/tasty-definitions-1.check +++ b/tests/run-macros/tasty-definitions-1.check @@ -56,32 +56,32 @@ Function22 Function23 Function24 Function25 -ImplicitFunction0 -ImplicitFunction1 -ImplicitFunction2 -ImplicitFunction3 -ImplicitFunction4 -ImplicitFunction5 -ImplicitFunction6 -ImplicitFunction7 -ImplicitFunction8 -ImplicitFunction9 -ImplicitFunction10 -ImplicitFunction11 -ImplicitFunction12 -ImplicitFunction13 -ImplicitFunction14 -ImplicitFunction15 -ImplicitFunction16 -ImplicitFunction17 -ImplicitFunction18 -ImplicitFunction19 -ImplicitFunction20 -ImplicitFunction21 -ImplicitFunction22 -ImplicitFunction23 -ImplicitFunction24 -ImplicitFunction25 +ContextFunction0 +ContextFunction1 +ContextFunction2 +ContextFunction3 +ContextFunction4 +ContextFunction5 +ContextFunction6 +ContextFunction7 +ContextFunction8 +ContextFunction9 +ContextFunction10 +ContextFunction11 +ContextFunction12 +ContextFunction13 +ContextFunction14 +ContextFunction15 +ContextFunction16 +ContextFunction17 +ContextFunction18 +ContextFunction19 +ContextFunction20 +ContextFunction21 +ContextFunction22 +ContextFunction23 +ContextFunction24 +ContextFunction25 ErasedFunction1 ErasedFunction2 ErasedFunction3 @@ -107,31 +107,31 @@ ErasedFunction22 ErasedFunction23 ErasedFunction24 ErasedFunction25 -ErasedImplicitFunction1 -ErasedImplicitFunction2 -ErasedImplicitFunction3 -ErasedImplicitFunction4 -ErasedImplicitFunction5 -ErasedImplicitFunction6 -ErasedImplicitFunction7 -ErasedImplicitFunction8 -ErasedImplicitFunction9 -ErasedImplicitFunction10 -ErasedImplicitFunction11 -ErasedImplicitFunction12 -ErasedImplicitFunction13 -ErasedImplicitFunction14 -ErasedImplicitFunction15 -ErasedImplicitFunction16 -ErasedImplicitFunction17 -ErasedImplicitFunction18 -ErasedImplicitFunction19 -ErasedImplicitFunction20 -ErasedImplicitFunction21 -ErasedImplicitFunction22 -ErasedImplicitFunction23 -ErasedImplicitFunction24 -ErasedImplicitFunction25 +ErasedContextFunction1 +ErasedContextFunction2 +ErasedContextFunction3 +ErasedContextFunction4 +ErasedContextFunction5 +ErasedContextFunction6 +ErasedContextFunction7 +ErasedContextFunction8 +ErasedContextFunction9 +ErasedContextFunction10 +ErasedContextFunction11 +ErasedContextFunction12 +ErasedContextFunction13 +ErasedContextFunction14 +ErasedContextFunction15 +ErasedContextFunction16 +ErasedContextFunction17 +ErasedContextFunction18 +ErasedContextFunction19 +ErasedContextFunction20 +ErasedContextFunction21 +ErasedContextFunction22 +ErasedContextFunction23 +ErasedContextFunction24 +ErasedContextFunction25 Tuple2 Tuple3 Tuple4