Skip to content

Commit 380c34d

Browse files
committed
Fix bug for reading type arguments in ClassfileParser
1 parent 09a87aa commit 380c34d

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

src/dotty/tools/dotc/Main.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import reporting.Reporter
1010

1111
/* To do:
1212
* - simplify hk types
13-
* - review isSubType
14-
* - have a second look at normalization (leave at method types if pt is method type?)
1513
* - Don't open package objects from class files if they are present in source
16-
* - check why we cannot access java.util.LinkedHashMap as a map
1714
* - Revise the way classes are inherited - when not followed by [...] or (...),
1815
* assume the unparameterized type and forward type parameters as we do now for the synthetic head class.
1916
*/

src/dotty/tools/dotc/config/Config.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ object Config {
1212

1313
final val checkConstraintsNonCyclic = true
1414

15+
final val flagInstantiationToNothing = false
16+
1517
/** Throw an exception if a deep subtype recursion is detected */
1618
final val flagDeepSubTypeRecursions = true
1719

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,11 @@ class TypeComparer(initctx: Context) extends DotClass {
354354
addConstraint(tp1, tp2, fromBelow = false) && {
355355
if ((!frozenConstraint) &&
356356
(tp2 isRef defn.NothingClass) &&
357-
ctx.typerState.isGlobalCommittable)
358-
ctx.log(s"!!! instantiated to Nothing: $tp1, constraint = ${constraint.show}")
357+
ctx.typerState.isGlobalCommittable) {
358+
def msg = s"!!! instantiated to Nothing: $tp1, constraint = ${constraint.show}"
359+
if (Config.flagInstantiationToNothing) assert(false, msg)
360+
else ctx.log(msg)
361+
}
359362
true
360363
}
361364
else (ctx.mode is Mode.TypevarsMissContext) || thirdTry(tp1, tp2)
@@ -437,7 +440,7 @@ class TypeComparer(initctx: Context) extends DotClass {
437440
ancestor2.exists && isSubType(tp1, ancestor2)
438441
}
439442
case _ =>
440-
def hasMatchingMember(name: Name): Boolean = /*>|>*/ traceIndented(s"hasMatchingMember($name) ${tp1.member(name)}") /*<|<*/ (
443+
def hasMatchingMember(name: Name): Boolean = /*>|>*/ ctx.traceIndented(s"hasMatchingMember($name) ${tp1.member(name)}", subtyping) /*<|<*/ (
441444
tp1.member(name).hasAltWith(alt => isSubType(alt.info, tp2.refinedInfo))
442445
||
443446
{ // special case for situations like:

src/dotty/tools/dotc/core/pickling/ClassfileParser.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ class ClassfileParser(
268268
else TypeBounds.lower(tp)
269269
case '*' => TypeBounds.empty
270270
}
271-
tp1 = RefinedType(tp, formals.head.name, bounds)
271+
tp1 = RefinedType(tp1, formals.head.name, bounds)
272272
case _ =>
273-
tp1 = RefinedType(tp, formals.head.name, TypeAlias(sig2type(tparams, skiptvs)))
273+
tp1 = RefinedType(tp1, formals.head.name, TypeAlias(sig2type(tparams, skiptvs)))
274274
}
275275
formals = formals.tail
276276
}

src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,9 @@ class SearchHistory(val searchDepth: Int, val seen: Map[ClassSymbol, Int]) {
626626

627627
/** A set of term references where equality is =:= */
628628
class TermRefSet(implicit ctx: Context) extends mutable.Traversable[TermRef] {
629-
private val elems = new mutable.LinkedHashMap[TermSymbol, List[Type]] // todo: change to j.u.LinkedHashMap?
630-
629+
import collection.JavaConverters._
630+
private val elems = (new java.util.LinkedHashMap[TermSymbol, List[Type]]).asScala
631+
631632
def += (ref: TermRef): Unit = {
632633
val pre = ref.prefix
633634
val sym = ref.symbol.asTerm

tests/pos/test.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
object test {
22

3-
import java.util.concurrent.{ Future, Callable, ExecutorService }
4-
def callable[T](body: => T): Callable[T] = new Callable[T] { override def call() = body }
3+
import collection.JavaConverters._
54

6-
7-
def xsubmit(x: Runnable): Future[_] = ???
8-
//def xsubmit[T](x: Runnable, y: T): Future[T] = ???
9-
def xsubmit[U](x: Callable[U]): Future[U] = ???
10-
def spawn0[V](body: V): Future[V] = xsubmit(callable(body))
5+
private val elems =
6+
(new java.util.LinkedHashMap[String, List[Int]]).asScala
7+
val elems2: collection.mutable.Map[String, List[Int]] = elems
118
}

0 commit comments

Comments
 (0)