diff options
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 11 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/TreeInfo.scala | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index eca1bbea5a..0e63e81ae1 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -687,6 +687,17 @@ trait Definitions extends api.StandardDefinitions { } } + // the argument types expected by the function described by `tp` (a FunctionN or SAM type), + // or `Nil` if `tp` does not represent a function type or SAM (or if it happens to be Function0...) + def functionOrSamArgTypes(tp: Type): List[Type] = { + val dealiased = tp.dealiasWiden + if (isFunctionTypeDirect(dealiased)) dealiased.typeArgs.init + else samOf(tp) match { + case samSym if samSym.exists => tp.memberInfo(samSym).paramTypes + case _ => Nil + } + } + // the SAM's parameters and the Function's formals must have the same length // (varargs etc don't come into play, as we're comparing signatures, not checking an application) def samMatchesFunctionBasedOnArity(sam: Symbol, formals: List[Any]): Boolean = diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 86b70643c9..b9f3e987ee 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -263,6 +263,12 @@ abstract class TreeInfo { true } + def isFunctionMissingParamType(tree: Tree): Boolean = tree match { + case Function(vparams, _) => vparams.exists(_.tpt.isEmpty) + case _ => false + } + + /** Is symbol potentially a getter of a variable? */ def mayBeVarGetter(sym: Symbol): Boolean = sym.info match { |