Skip to content

Commit

Permalink
ignore GADT related issues for now
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengyun committed Mar 8, 2018
1 parent e8c83f3 commit 2e38f70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
24 changes: 2 additions & 22 deletions compiler/src/dotty/tools/dotc/transform/IsInstanceOfChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ object Checkable {
* 4. if `P = Array[T]`, checkable(E, T) where `E` is the element type of `X`, defaults to `Any`.
* 5. if `P` is `pre.F[Ts]` and `pre.F` refers to a class which is not `Array`:
* (a) replace `Ts` with fresh type variables `Xs`
* (b) constrain `Xs` with `pre.F[Xs] <:< X`,
* if `X` cannot be uniquely determined, instantiate `X` with fresh type symbol.
* (b) constrain `Xs` with `pre.F[Xs] <:< X`
* (c) instantiate Xs and check `pre.F[Xs] <:< P`
* 6. if `P = T1 | T2` or `P = T1 & T2`, checkable(X, T1) && checkable(X, T2).
* 7. if `P` is a refinement type, FALSE
Expand Down Expand Up @@ -101,26 +100,7 @@ object Checkable {

P1 <:< X // may fail, ignore

// 3324g.scala cannot happen in such cases
def canInstantiate =
tycon.classSymbol.is(Final) ||
!X.classSymbol.is(Trait) ||
X.classSymbol.typeParams.isEmpty

if (canInstantiate)
maximizeType(P1, pos, fromScala2x = true) // use `fromScala2x = true` to force instantiate invariant tvars
else
tvars.foreach { case tvar: TypeVar =>
val bounds = ctx.typerState.constraint.entry(tvar.origin)
if (bounds.loBound =:= bounds.hiBound)
tvar.instantiateWith(bounds.loBound)
else { // 3324g.scala
val wildCard = ctx.newSymbol(ctx.owner, WildcardParamName.fresh().toTypeName, Case, tvar.origin.underlying, coord = pos)
tvar.instantiateWith(wildCard.typeRef)
}
}

val res = P1 <:< P
val res = isFullyDefined(P1, ForceDegree.noBottom) && P1 <:< P
debug.println("P1 : " + P1)
debug.println("P1 <:< P = " + res)

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/isInstanceOf/3324g.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Test {
}

def quux[T](a: A[T]): Unit = a match {
case _: B[T] => // error
case _: B[T] => // err-or: cannot handle this for now
}

quux(new C[Int])
Expand Down

0 comments on commit 2e38f70

Please sign in to comment.