diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-11-02 11:08:28 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-11-22 01:35:07 +0100 |
commit | 8a61ff432543a29234193cd1f7c14abd3f3d31a0 (patch) | |
tree | a8147561d307af862c295cfc8100d271063bb0dd /compiler/src/dotty/tools/dotc/core/Types.overflow | |
parent | 6a455fe6da5ff9c741d91279a2dc6fe2fb1b472f (diff) | |
download | dotty-8a61ff432543a29234193cd1f7c14abd3f3d31a0.tar.gz dotty-8a61ff432543a29234193cd1f7c14abd3f3d31a0.tar.bz2 dotty-8a61ff432543a29234193cd1f7c14abd3f3d31a0.zip |
Move compiler and compiler tests to compiler dir
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Types.overflow')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Types.overflow | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Types.overflow b/compiler/src/dotty/tools/dotc/core/Types.overflow new file mode 100644 index 000000000..77f1f6fc1 --- /dev/null +++ b/compiler/src/dotty/tools/dotc/core/Types.overflow @@ -0,0 +1,66 @@ +object Types { + class Type { + + /** The non-private symbol with given name in the given class that matches this type. + * @param inClass The class containing the symbol's definition + * @param name The name of the symbol we are looking for + * @param site The base type from which member types are computed + def matchingTermSymbol(inClass: Symbol, name: Name, site: Type)(implicit ctx: Context): Symbol = { + var denot = inClass.info.nonPrivateDecl(name) + if (denot.isTerm) { // types of the same name always match + if (denot.isOverloaded) + denot = denot.atSignature(this.signature) // seems we need two kinds of signatures here + if (!(site.memberInfo(denot.symbol) matches this)) + denot = NoDenotation + } + denot.symbol + } + + final def firstParamTypes: List[Type] = this match { + case mt: MethodType => mt.paramTypes + case pt: PolyType => pt.firstParamTypes + case _ => Nil + } + + /** `tp` is either a type variable or poly param. Returns + * Covariant if all occurrences of `tp` in this type are covariant + * Contravariant if all occurrences of `tp` in this type are contravariant + * Covariant | Contravariant if there are no occurrences of `tp` in this type + * EmptyFlags if `tp` occurs noon-variantly in this type + */ + def varianceOf(tp: Type): FlagSet = ??? + + + } + + class AndType extends Type { + + def derived_& (tp1: Type, tp2: Type)(implicit ctx: Context) = + if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this + else tp1 & tp2 + + } + + class OrType extends Type { + + def derived_| (tp1: Type, tp2: Type)(implicit ctx: Context) = + if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this + else tp1 | tp2 + + } + + class MethodType { + /* probably won't be needed + private var _isVarArgs: Boolean = _ + private var knownVarArgs: Boolean = false + + def isVarArgs(implicit ctx: Context) = { + if (!knownVarArgs) { + _isVarArgs = paramTypes.nonEmpty && paramTypes.last.isRepeatedParam + knownVarArgs = true + } + _isVarArgs + } + */ + } +}
\ No newline at end of file |