summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-01-29 10:29:33 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-01-29 10:29:33 +1000
commit8b334459d0e09cf486b12ea6869ddc2f2a9eb6a6 (patch)
tree9b91ee264a8a4abf936b4b2c939591decb751313 /src/compiler/scala/tools/nsc/typechecker
parent020581e795a677b838fa62f67064fe9a55b02ba0 (diff)
parent7b5998a0592ee707c02a13859fe1520687c76c38 (diff)
downloadscala-8b334459d0e09cf486b12ea6869ddc2f2a9eb6a6.tar.gz
scala-8b334459d0e09cf486b12ea6869ddc2f2a9eb6a6.tar.bz2
scala-8b334459d0e09cf486b12ea6869ddc2f2a9eb6a6.zip
Merge remote-tracking branch 'origin/2.11.x' into merge/2.11.x-to-2.12.x-20150129
Conflicts: build.number src/library/scala/concurrent/Future.scala versions.properties
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala26
9 files changed, 36 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 866ca37303..5c36bd9d28 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -73,7 +73,7 @@ trait ContextErrors {
// 2) provide the type of the implicit parameter for which we got diverging expansion
// (pt at the point of divergence gives less information to the user)
// Note: it is safe to delay error message generation in this case
- // becasue we don't modify implicits' infos.
+ // because we don't modify implicits' infos.
case class DivergentImplicitTypeError(underlyingTree: Tree, pt0: Type, sym: Symbol)
extends TreeTypeError {
def errMsg: String = errMsgForPt(pt0)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index a21c7cc27e..b3e207b334 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -145,7 +145,7 @@ trait Contexts { self: Analyzer =>
* - A variety of bits that track the current error reporting policy (more on this later);
* whether or not implicits/macros are enabled, whether we are in a self or super call or
* in a constructor suffix. These are represented as bits in the mask `contextMode`.
- * - Some odds and ends: undetermined type pararameters of the current line of type inference;
+ * - Some odds and ends: undetermined type parameters of the current line of type inference;
* contextual augmentation for error messages, tracking of the nesting depth.
*
* And behaviour:
@@ -154,19 +154,19 @@ trait Contexts { self: Analyzer =>
* to buffer these for use in 'silent' type checking, when some recovery might be possible.
* - `Context` is something of a Zipper for the tree were are typechecking: it `enclosingContextChain`
* is the path back to the root. This is exactly what we need to resolve names (`lookupSymbol`)
- * and to collect in-scope implicit defintions (`implicitss`)
+ * and to collect in-scope implicit definitions (`implicitss`)
* Supporting these are `imports`, which represents all `Import` trees in in the enclosing context chain.
- * - In a similar vein, we can assess accessiblity (`isAccessible`.)
+ * - In a similar vein, we can assess accessibility (`isAccessible`.)
*
* More on error buffering:
* When are type errors recoverable? In quite a few places, it turns out. Some examples:
* trying to type an application with/without the expected type, or with/without implicit views
* enabled. This is usually mediated by `Typer.silent`, `Inferencer#tryTwice`.
*
- * Intially, starting from the `typer` phase, the contexts either buffer or report errors;
+ * Initially, starting from the `typer` phase, the contexts either buffer or report errors;
* afterwards errors are thrown. This is configured in `rootContext`. Additionally, more
* fine grained control is needed based on the kind of error; ambiguity errors are often
- * suppressed during exploraratory typing, such as determining whether `a == b` in an argument
+ * suppressed during exploratory typing, such as determining whether `a == b` in an argument
* position is an assignment or a named argument, when `Infererencer#isApplicableSafe` type checks
* applications with and without an expected type, or whtn `Typer#tryTypedApply` tries to fit arguments to
* a function type with/without implicit views.
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 7ed4fe1f88..4435ed0b60 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -3,7 +3,7 @@
* @author Martin Odersky
*/
-//todo: rewrite or disllow new T where T is a mixin (currently: <init> not a member of T)
+//todo: rewrite or disallow new T where T is a mixin (currently: <init> not a member of T)
//todo: use inherited type info also for vars and values
//todo: disallow C#D in superclass
//todo: treat :::= correctly
@@ -159,7 +159,7 @@ trait Implicits {
* @param tree The tree representing the implicit
* @param subst A substituter that represents the undetermined type parameters
* that were instantiated by the winning implicit.
- * @param undetparams undeterminted type parameters
+ * @param undetparams undetermined type parameters
*/
class SearchResult(val tree: Tree, val subst: TreeTypeSubstituter, val undetparams: List[Symbol]) {
override def toString = "SearchResult(%s, %s)".format(tree,
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 8979b26719..cf97474d9a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1017,7 +1017,7 @@ trait Infer extends Checkable {
/** Substitute free type variables `undetparams` of type constructor
* `tree` in pattern, given prototype `pt`.
*
- * @param tree the constuctor that needs to be instantiated
+ * @param tree the constructor that needs to be instantiated
* @param undetparams the undetermined type parameters
* @param pt0 the expected result type of the instance
*/
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 0bb94be636..711cfba24d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -171,7 +171,7 @@ trait Namers extends MethodSynthesis {
val newFlags = (sym.flags & LOCKED) | flags
sym.rawInfo match {
case tr: TypeRef =>
- // !!! needed for: pos/t5954d; the uniques type cache will happilly serve up the same TypeRef
+ // !!! needed for: pos/t5954d; the uniques type cache will happily serve up the same TypeRef
// over this mutated symbol, and we witness a stale cache for `parents`.
tr.invalidateCaches()
case _ =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index b6387fd56b..50f658f68d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -384,7 +384,7 @@ trait NamesDefaults { self: Analyzer =>
* of arguments.
*
* @param args The list of arguments
- * @param params The list of parameter sybols of the invoked method
+ * @param params The list of parameter symbols of the invoked method
* @param argName A function that extracts the name of an argument expression, if it is a named argument.
*/
def missingParams[T](args: List[T], params: List[Symbol], argName: T => Option[Name]): (List[Symbol], Boolean) = {
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
index bb8c3c3c6d..fa4a764f1b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
@@ -336,7 +336,7 @@ trait PatternTypers {
val app = atPos(uncheckedPattern.pos)(Apply(classTagExtractor, args))
// must call doTypedUnapply directly, as otherwise we get undesirable rewrites
// and re-typechecks of the target of the unapply call in PATTERNmode,
- // this breaks down when the classTagExtractor (which defineds the unapply member) is not a simple reference to an object,
+ // this breaks down when the classTagExtractor (which defines the unapply member) is not a simple reference to an object,
// but an arbitrary tree as is the case here
val res = doTypedUnapply(app, classTagExtractor, classTagExtractor, args, PATTERNmode, pt)
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index c03fd3345f..8f13507fa9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -153,7 +153,7 @@ trait SyntheticMethods extends ast.TreeDSL {
def thatCast(eqmeth: Symbol): Tree =
gen.mkCast(Ident(eqmeth.firstParam), clazz.tpe)
- /* The equality method core for case classes and inline clases.
+ /* The equality method core for case classes and inline classes.
* 1+ args:
* (that.isInstanceOf[this.C]) && {
* val x$1 = that.asInstanceOf[this.C]
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index efe40b11f2..2dd79075ee 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -950,7 +950,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// Ignore type errors raised in later phases that are due to mismatching types with existential skolems
// We have lift crashing in 2.9 with an adapt failure in the pattern matcher.
- // Here's my hypothsis why this happens. The pattern matcher defines a variable of type
+ // Here's my hypothesis why this happens. The pattern matcher defines a variable of type
//
// val x: T = expr
//
@@ -3285,6 +3285,22 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
handleOverloaded
+ case _ if isPolymorphicSignature(fun.symbol) =>
+ // Mimic's Java's treatment of polymorphic signatures as described in
+ // https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.12.3
+ //
+ // One can think of these methods as being infinitely overloaded. We create
+ // a ficticious new cloned method symbol for each call site that takes on a signature
+ // governed by a) the argument types and b) the expected type
+ val args1 = typedArgs(args, forArgMode(fun, mode))
+ val pts = args1.map(_.tpe.deconst)
+ val clone = fun.symbol.cloneSymbol
+ val cloneParams = pts map (pt => clone.newValueParameter(currentUnit.freshTermName()).setInfo(pt))
+ val resultType = if (isFullyDefined(pt)) pt else ObjectTpe
+ clone.modifyInfo(mt => copyMethodType(mt, cloneParams, resultType))
+ val fun1 = fun.setSymbol(clone).setType(clone.info)
+ doTypedApply(tree, fun1, args1, mode, resultType).setType(resultType)
+
case mt @ MethodType(params, _) =>
val paramTypes = mt.paramTypes
// repeat vararg as often as needed, remove by-name
@@ -3780,8 +3796,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
case TypeRef(pre, sym, args) =>
if (sym.isAliasType && containsLocal(tp) && (tp.dealias ne tp)) apply(tp.dealias)
else {
- if (pre.isVolatile)
- InferTypeWithVolatileTypeSelectionError(tree, pre)
+ if (pre.isVolatile) pre match {
+ case SingleType(_, sym) if sym.isSynthetic && isPastTyper =>
+ debuglog(s"ignoring volatility of prefix in pattern matcher generated inferred type: $tp") // See pos/t7459c.scala
+ case _ =>
+ InferTypeWithVolatileTypeSelectionError(tree, pre)
+ }
mapOver(tp)
}
case _ =>