diff options
author | Martin Odersky <odersky@gmail.com> | 2016-01-10 16:08:04 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-02-19 14:00:00 +0100 |
commit | 6947b630bada85dabd7904ecf5d1da724c5d281d (patch) | |
tree | 06f1bb26eac234b854f34848f612ee1acaa23ae0 | |
parent | 3363c4e4dde98d58e99f7d7ce44f5cc206cef4c7 (diff) | |
download | dotty-6947b630bada85dabd7904ecf5d1da724c5d281d.tar.gz dotty-6947b630bada85dabd7904ecf5d1da724c5d281d.tar.bz2 dotty-6947b630bada85dabd7904ecf5d1da724c5d281d.zip |
Augment test case
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 14 | ||||
-rw-r--r-- | tests/pos/named-params.scala | 7 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 4251648a3..420333695 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -444,10 +444,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object. case tp: TypeRef => tp case tp @ RefinedType(tp1, name: TypeName) => - val prevInfo = refinements(name) - refinements = refinements.updated(name, - if (prevInfo == null) tp.refinedInfo else prevInfo & tp.refinedInfo) - formals = formals.updated(name, tp1.typeParamNamed(name)) + tp.refinedInfo match { + case TypeAlias(TypeRef(pre, name1)) if (pre eq cls.thisType) && name1 == name => + // Don't record refinements of the form X = this.X (These can arise using named parameters). + typr.println(s"dropping refinement $tp") + case _ => + val prevInfo = refinements(name) + refinements = refinements.updated(name, + if (prevInfo == null) tp.refinedInfo else prevInfo & tp.refinedInfo) + formals = formals.updated(name, tp1.typeParamNamed(name)) + } normalizeToRef(tp1) case ErrorType => defn.AnyType diff --git a/tests/pos/named-params.scala b/tests/pos/named-params.scala index 51041078d..9f1410bef 100644 --- a/tests/pos/named-params.scala +++ b/tests/pos/named-params.scala @@ -1,10 +1,10 @@ package namedparams -abstract class C[type Elem, type Value](val elem: Elem) { +class C[type Elem, type Value](val elem: Elem) { def toVal: Elem = ??? } - +abstract class D[type Elem, V](elem: Elem) extends C[Elem, V](elem) object Test { val c = new C[String, String]("A") { @@ -13,5 +13,8 @@ object Test { val x: c.Elem = c.elem val c2: C { type Elem = String } = c + + val c3 = new C[Elem = String, Value = Int]("B") + val c4 = new C[Elem = String]("C") val x2: c2.Elem = c2.elem } |