diff options
-rw-r--r-- | src/dotty/tools/dotc/core/Substituters.scala | 13 | ||||
-rw-r--r-- | tests/pos/extmethods.scala | 11 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala index 0d1c78e2f..23683608a 100644 --- a/src/dotty/tools/dotc/core/Substituters.scala +++ b/src/dotty/tools/dotc/core/Substituters.scala @@ -102,14 +102,13 @@ trait Substituters { this: Context => } if (sym.isStatic && !existsStatic(from)) tp else { - val prefix1 = substDealias(tp.prefix, from, to, theMap) - if (prefix1 ne tp.prefix) tp.derivedSelect(prefix1) - else if (sym.isAliasType) { - val hi = sym.info.bounds.hi - val hi1 = substDealias(hi, from, to, theMap) - if (hi1 eq hi) tp else hi1 + tp.info match { + case TypeAlias(alias) => + val alias1 = substDealias(alias, from, to, theMap) + if (alias1 ne alias) return alias1 + case _ => } - else tp + tp.derivedSelect(substDealias(tp.prefix, from, to, theMap)) } case _: ThisType | _: BoundType | NoPrefix => tp diff --git a/tests/pos/extmethods.scala b/tests/pos/extmethods.scala index cac1c4ec1..fe95a1c79 100644 --- a/tests/pos/extmethods.scala +++ b/tests/pos/extmethods.scala @@ -9,3 +9,14 @@ class Foo[+A <: AnyRef](val xs: List[A]) extends AnyVal { def baz[B >: A](x: B): List[B] = ??? } +object CollectionStrawMan { + import collection.mutable.ArrayBuffer + import reflect.ClassTag + + implicit class ArrayOps[A](val xs: Array[A]) extends AnyVal { + + def elemTag: ClassTag[A] = ClassTag(xs.getClass.getComponentType) + + protected[this] def newBuilder = new ArrayBuffer[A].mapResult(_.toArray(elemTag)) + } +} |