aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/printing/Disambiguation.scala6
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala23
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala4
5 files changed, 23 insertions, 19 deletions
diff --git a/src/dotty/tools/dotc/printing/Disambiguation.scala b/src/dotty/tools/dotc/printing/Disambiguation.scala
index 196b8f1ae..b830b353a 100644
--- a/src/dotty/tools/dotc/printing/Disambiguation.scala
+++ b/src/dotty/tools/dotc/printing/Disambiguation.scala
@@ -31,7 +31,11 @@ object Disambiguation {
private def recordedNameString(sym: Symbol): String = {
val str = rawNameString(sym)
- val existing = variants.getOrElse(str, new mutable.ListBuffer)
+ val existing = variants.getOrElse(str, new mutable.ListBuffer[Symbol])
+ // Dotty deviation: without a type parameter on ListBuffer, inference
+ // will compute ListBuffer[Symbol] | ListBuffer[Nothing] as the type of "existing"
+ // and then the assignment to variants below will fail.
+ // We need to find a way to avoid such useless inferred types.
if (!(existing contains sym)) {
hasConflicts |= existing.nonEmpty
variants(str) = (existing += sym)
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 644227878..d5f9bded1 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -448,7 +448,7 @@ trait Applications extends Compatibility { self: Typer =>
// try with prototype `[].name(args)`, this might succeed by inserting an
// implicit conversion around []. (an example is Int + BigInt).
tryEither { implicit ctx =>
- val qual1 = adaptInterpolated(qual, new SelectionProto(name, proto))
+ val qual1 = adaptInterpolated(qual, new SelectionProto(name, proto, NoViewsAllowed))
if (qual eq qual1) ctx.error("no progress")
if (ctx.reporter.hasErrors) qual1
else
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 396bf2538..2c3914800 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -33,7 +33,7 @@ object Implicits {
/** A common base class of contextual implicits and of-type implicits which
* represents as set of implicit references.
*/
- abstract class ImplicitRefs(initctx: Context) extends Compatibility {
+ abstract class ImplicitRefs(initctx: Context) {
implicit val ctx: Context =
if (initctx == NoContext) initctx else initctx retractMode Mode.ImplicitsEnabled
@@ -43,13 +43,10 @@ object Implicits {
/** Return those references in `refs` that are compatible with type `pt`. */
protected def filterMatching(pt: Type)(implicit ctx: Context): List[TermRef] = track("filterMatching") {
def refMatches(ref: TermRef)(implicit ctx: Context) =
- (ref.symbol isAccessibleFrom ref.prefix) && isCompatible(normalize(ref, pt), pt)
+ (ref.symbol isAccessibleFrom ref.prefix) && NoViewsAllowed.isCompatible(normalize(ref, pt), pt)
refs filter (refMatches(_)(ctx.fresh.withExploreTyperState.addMode(Mode.TypevarsMissContext))) // create a defensive copy of ctx to avoid constraint pollution
}
-
- /** No further implicit conversions can be applied when searching for implicits. */
- override def viewExists(tp: Type, pt: Type)(implicit ctx: Context) = false
}
/** The implicit references coming from the implicit scope of a type.
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index cfcf882f4..196cd8408 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -63,17 +63,20 @@ object Inferencing {
}
}
+ object NoViewsAllowed extends Compatibility {
+ override def viewExists(tp: Type, pt: Type)(implicit ctx: Context): Boolean = false
+ }
+
/** A prototype for expressions [] that are part of a selection operation:
*
* [ ].name: proto
*/
- class SelectionProto(val name: Name, proto: Type)
- extends RefinedType(WildcardType, name)(_ => proto) with ProtoType with Compatibility {
- override def viewExists(tp: Type, pt: Type)(implicit ctx: Context): Boolean = false
+ class SelectionProto(val name: Name, proto: Type, compat: Compatibility)
+ extends RefinedType(WildcardType, name)(_ => proto) with ProtoType {
override def isMatchedBy(tp1: Type)(implicit ctx: Context) =
name == nme.WILDCARD || {
val mbr = tp1.member(name)
- mbr.exists && mbr.hasAltWith(m => normalizedCompatible(m.info, proto))
+ mbr.exists && mbr.hasAltWith(m => compat.normalizedCompatible(m.info, proto))
}
override def toString = "Proto" + super.toString
override def derivedRefinedType(parent: Type, refinedName: Name, refinedInfo: Type)(implicit ctx: Context): RefinedType = {
@@ -81,7 +84,7 @@ object Inferencing {
if (tp1 eq this) this
else {
assert(parent == WildcardType)
- new SelectionProto(refinedName1, tp1.refinedInfo)
+ new SelectionProto(refinedName1, tp1.refinedInfo, compat)
}
}
def map(tm: TypeMap) = tm(this).asInstanceOf[SelectionProto]
@@ -91,12 +94,12 @@ object Inferencing {
/** Create a selection proto-type, but only one level deep;
* treat constructors specially
*/
- def selectionProto(name: Name, tp: Type) =
+ def selectionProto(name: Name, tp: Type, typer: Typer) =
if (name.isConstructorName) WildcardType
else tp match {
case tp: UnapplyFunProto => new UnapplySelectionProto(name)
- case tp: ProtoType => new SelectionProto(name, WildcardType)
- case _ => new SelectionProto(name, tp)
+ case tp: ProtoType => new SelectionProto(name, WildcardType, typer)
+ case _ => new SelectionProto(name, tp, typer)
}
/** A prototype for expressions [] that are in some unspecified selection operation
@@ -107,10 +110,10 @@ object Inferencing {
* operation is further selection. In this case, the expression need not be a value.
* @see checkValue
*/
- object AnySelectionProto extends SelectionProto(nme.WILDCARD, WildcardType)
+ object AnySelectionProto extends SelectionProto(nme.WILDCARD, WildcardType, NoViewsAllowed)
/** A prototype for selections in pattern constructors */
- class UnapplySelectionProto(name: Name) extends SelectionProto(name, WildcardType)
+ class UnapplySelectionProto(name: Name) extends SelectionProto(name, WildcardType, NoViewsAllowed)
trait ApplyingProto extends ProtoType
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 61ab0ed56..f565e72c9 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -371,7 +371,7 @@ class Typer extends Namer with Applications with Implicits {
}
def typedSelect(tree: untpd.Select, pt: Type)(implicit ctx: Context): Tree = track("typedSelect") {
- val qual1 = typedExpr(tree.qualifier, selectionProto(tree.name, pt))
+ val qual1 = typedExpr(tree.qualifier, selectionProto(tree.name, pt, this))
val ownType = checkedSelectionType(qual1, tree)
checkValue(ownType, pt, tree.pos)
cpy.Select(tree, qual1, tree.name).withType(ownType)
@@ -747,7 +747,7 @@ class Typer extends Namer with Applications with Implicits {
}
def typedSelectFromTypeTree(tree: untpd.SelectFromTypeTree, pt: Type)(implicit ctx: Context): SelectFromTypeTree = track("typedSelectFromTypeTree") {
- val qual1 = typedType(tree.qualifier, selectionProto(tree.name, pt))
+ val qual1 = typedType(tree.qualifier, selectionProto(tree.name, pt, this))
cpy.SelectFromTypeTree(tree, qual1, tree.name).withType(checkedSelectionType(qual1, tree))
}