aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/ParamInfo.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-16 15:15:28 +0100
committerMartin Odersky <odersky@gmail.com>2017-04-06 13:15:27 +0200
commitc024a6037f3dd7e7458d936566cd4b653b8b7545 (patch)
treeaae9b2e9b332fc166a04f1b29f1ff4e62fdd6216 /compiler/src/dotty/tools/dotc/core/ParamInfo.scala
parent549bd812684e6f269610234ddefe8054dfb42746 (diff)
downloaddotty-c024a6037f3dd7e7458d936566cd4b653b8b7545.tar.gz
dotty-c024a6037f3dd7e7458d936566cd4b653b8b7545.tar.bz2
dotty-c024a6037f3dd7e7458d936566cd4b653b8b7545.zip
Break out functionality from MethodType
and generalize MethodParam to ParamRef, and TypeParamInfo to ParamInfo
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/ParamInfo.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/ParamInfo.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/ParamInfo.scala b/compiler/src/dotty/tools/dotc/core/ParamInfo.scala
new file mode 100644
index 000000000..efae24916
--- /dev/null
+++ b/compiler/src/dotty/tools/dotc/core/ParamInfo.scala
@@ -0,0 +1,40 @@
+package dotty.tools.dotc.core
+
+import Names.TypeName
+import Contexts.Context
+import Types.{Type, TypeBounds}
+
+/** A common super trait of Symbol and LambdaParam.
+ * Used to capture the attributes of type parameters which can be implemented as either.
+ */
+trait ParamInfo {
+
+ /** Is this the info of a type parameter? Will return `false` for symbols
+ * that are not type parameters.
+ */
+ def isTypeParam(implicit ctx: Context): Boolean
+
+ /** The name of the type parameter */
+ def paramName(implicit ctx: Context): TypeName
+
+ /** The info of the type parameter */
+ def paramInfo(implicit ctx: Context): Type
+
+ /** The info of the type parameter as seen from a prefix type.
+ * For type parameter symbols, this is the `memberInfo` as seen from `prefix`.
+ * For type lambda parameters, it's the same as `paramBounds` as
+ * `asSeenFrom` has already been applied to the whole type lambda.
+ */
+ def paramInfoAsSeenFrom(pre: Type)(implicit ctx: Context): Type
+
+ /** The parameter bounds, or the completer if the type parameter
+ * is an as-yet uncompleted symbol.
+ */
+ def paramInfoOrCompleter(implicit ctx: Context): Type
+
+ /** The variance of the type parameter */
+ def paramVariance(implicit ctx: Context): Int
+
+ /** A type that refers to the parameter */
+ def paramRef(implicit ctx: Context): Type
+} \ No newline at end of file